Skip to content
This repository has been archived by the owner on May 28, 2020. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhaotailang committed Mar 27, 2017
1 parent 64f445c commit 7815734
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 97 deletions.
5 changes: 5 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
# Espresso Android App
![icon](https://github.com/TonnyL/Espresso/blob/master/mobile/src/main/res/mipmap-xxxhdpi/ic_launcher.png)

Espresso is an express delivery tracking app designed with Material Design style, built on MVP(Model-View-Presenter) architecture with RxJava2, Retrofit2 and Realm database.

The source code in this repository reflects the app which supports mobile devices running Android 5.0+ and wearable devices running Android Wear 2.0+.
The source code in this repository reflects the app which supports mobile devices running Android 5.0+.

### Features
With this app, you can:

+ Support over 600 express companies.
+ Add packages by inputting the package number or just scanning the express sheet.
+ View the package's detais such as the latest location
+ Search infomation about the express companies.
+ Recognize the company of a package automatically.
+ View the package's details such as the latest location.
+ Search information about the express companies.
+ Launcher widgets.
+ Get important notification when the package is on delivery.
+ Send feedback on using experience from your devices.
+ Support Android Wear devices.

### Screenshots
![screenshot0](http://upload-images.jianshu.io/upload_images/2440049-649b96f3b8858cce.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

![screenshot1](http://upload-images.jianshu.io/upload_images/2440049-d3c50d9e5ca6f0a4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

### How to Work with the Source
I hope the source code for this app is useful for you as a reference or starting point for creating your own app. Here is some instructions to help you better build and run the code in Android Studio.
Expand All @@ -32,22 +41,26 @@ Notice: If you want to review a different branch, replace the `master` with the

Suggestion: It is better for you to update your Android Studio to version 2.3 when you open this project.

### Todos
### To-dos
This project is still in progress. Here are the some features that I will finish in the future.

- [x] Refreshing package details by accessing the network.
- [x] Launcher app widgets.
- [x] App Shortcuts on devices that running Android 7.1+.
- [x] Material design app onboarding pages.
- [ ] Chrome Custom Tabs.
- [ ] Alphabet indexing for companies list.
- [x] Alphabet indexing for companies list.
- [ ] Search packages and companies.
- [ ] Day and night mode.
- [x] Service to build notifications.
- [x] Settings and about page.
- [ ] Supporting Android Wear.
- [ ] UI test and unit test.

### Help Me Improve This App
+ As you can see at the screenshots, some images in Espresso app are not suitable. So if you are a designer and familiar with **Material Design** and want to help me make the app look better, please email me.
+ If you want to improve the translation of Espresso, do not hesitate to email me. Let us make Espresso more and more popular all over the world.

### Libraries Used in This App
Name | Introduction | Version
----- | ------ | ---
Expand All @@ -63,9 +76,11 @@ Name | Introduction | Version

### Thanks to
+ [Express 100](https://www.kuaidi100.com/)
+ [googlesamples](https://github.com/googlesamples) - [android-architecture](https://github.com/googlesamples/android-architecture)
+ [google](https://github.com/google) - [iosched](https://github.com/google/iosched)
+ [fython](https://github.com/fython) - [PackageTracker](https://github.com/fython/PackageTracker)
+ [googlesamples](https://github.com/googlesamples) - [android-architecture](https://github.com/googlesamples/android-architecture):A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.
+ [google](https://github.com/google) - [iosched](https://github.com/google/iosched):The Google I/O 2016 Android App.
+ [fython](https://github.com/fython) - [PackageTracker](https://github.com/fython/PackageTracker):The New ExpressHelper for Android.
+ [hefuyicoder](https://github.com/hefuyicoder) - [ListenerMusicPlayer](https://github.com/hefuyicoder/ListenerMusicPlayer):A Grace Material Design Music Player.
+ [BreadKid](https://github.com/BreadKid) - [SearchItem](https://github.com/BreadKid/SearchItem):小搜搜——商品条形码/二维码搜索APP.
+ [YoulunZhai](https://plus.google.com/+YoulunZhai) - The posters.
+ Other people who help me solve the problems when I met some difficult bugs.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.reactivex.Observable;
import io.realm.Case;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.Sort;

/**
Expand All @@ -37,10 +36,7 @@ public static CompaniesLocalDataSource getInstance() {

@Override
public Observable<List<Company>> getCompanies() {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
return Observable
.fromIterable(rlm.copyFromRealm(rlm.where(Company.class).findAllSorted("alphabet", Sort.ASCENDING)))
.toList()
Expand All @@ -49,20 +45,14 @@ public Observable<List<Company>> getCompanies() {

@Override
public Observable<Company> getCompany(@NonNull String companyId) {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
return Observable
.just(rlm.copyFromRealm(rlm.where(Company.class).equalTo("id", companyId).findFirst()));
}

@Override
public void initData() {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();

rlm.beginTransaction();
rlm.createOrUpdateObjectFromJson(Company.class, "{'name':'申通快递','id':'shentong','tel':'95543','website':'http://www.sto.cn','alphabet':'shentongkuaidi','avatar':'#00BCD4'}");
Expand Down Expand Up @@ -713,10 +703,7 @@ public void initData() {

@Override
public Observable<List<Company>> searchCompanies(@NonNull String keyWords) {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
List<Company> results = rlm.copyFromRealm(
rlm.where(Company.class)
.like("name","*" + keyWords + "*", Case.INSENSITIVE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.reactivex.Observable;
import io.realm.Case;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmResults;
import io.realm.Sort;

Expand Down Expand Up @@ -49,10 +48,7 @@ public static void destroyInstance() {
*/
@Override
public Observable<List<Package>> getPackages() {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();

return Observable.just(rlm.copyFromRealm(rlm.where(Package.class)
.findAllSorted("timestamp", Sort.DESCENDING)));
Expand All @@ -67,10 +63,7 @@ public Observable<List<Package>> getPackages() {
*/
@Override
public Observable<Package> getPackage(@NonNull String packNumber) {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
return Observable.just(rlm.copyFromRealm(rlm.where(Package.class)
.equalTo("number", packNumber)
.findFirst()));
Expand All @@ -82,10 +75,7 @@ public Observable<Package> getPackage(@NonNull String packNumber) {
*/
@Override
public void savePackage(@NonNull Package pack) {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
// DO NOT forget begin and commit the transaction.
rlm.beginTransaction();
rlm.copyToRealmOrUpdate(pack);
Expand All @@ -101,10 +91,7 @@ public void savePackage(@NonNull Package pack) {
*/
@Override
public void deletePackage(@NonNull String packageId) {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
Package p = rlm.where(Package.class)
.equalTo("number", packageId)
.findFirst();
Expand Down Expand Up @@ -135,10 +122,7 @@ public Observable<Package> refreshPackage(@NonNull String packageId) {
*/
@Override
public void setAllPackagesRead() {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
List<Package> results = rlm.copyFromRealm(rlm.where(Package.class).findAll());

for (Package p : results) {
Expand All @@ -160,10 +144,7 @@ public void setAllPackagesRead() {
*/
@Override
public void setPackageReadable(@NonNull String packageId, boolean readable) {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
Package p = rlm.copyFromRealm(rlm.where(Package.class)
.equalTo("number", packageId)
.findFirst());
Expand All @@ -186,10 +167,7 @@ public void setPackageReadable(@NonNull String packageId, boolean readable) {
*/
@Override
public boolean isPackageExist(@NonNull String packageId) {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
RealmResults<Package> results = rlm.where(Package.class)
.equalTo("number", packageId)
.findAll();
Expand All @@ -198,10 +176,7 @@ public boolean isPackageExist(@NonNull String packageId) {

@Override
public void updatePackageName(@NonNull String packageId, @NonNull String name) {
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();
Package p = rlm.where(Package.class)
.equalTo("number", packageId)
.findFirst();
Expand All @@ -216,7 +191,7 @@ public void updatePackageName(@NonNull String packageId, @NonNull String name) {

@Override
public Observable<List<Package>> searchPackages(@NonNull String keyWords) {
Realm rlm = newRealmInstance();
Realm rlm = RealmHelper.newRealmInstance();
return Observable.fromIterable(rlm.copyFromRealm(
rlm.where(Package.class)
.like("companyChineseName", "*" + keyWords + "*", Case.INSENSITIVE)
Expand All @@ -227,11 +202,4 @@ public Observable<List<Package>> searchPackages(@NonNull String keyWords) {
.toObservable();
}

private Realm newRealmInstance() {
return Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.github.marktony.espresso.realm;

import io.realm.Realm;
import io.realm.RealmConfiguration;

/**
* Created by lizhaotailang on 2017/3/22.
*/
Expand All @@ -8,4 +11,11 @@ public class RealmHelper {

public static final String DATABASE_NAME = "Espresso.realm";

public static Realm newRealmInstance() {
return Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(RealmHelper.DATABASE_NAME)
.build());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.github.marktony.espresso.appwidget.AppWidgetProvider;
import io.github.marktony.espresso.data.Package;
import io.github.marktony.espresso.mvp.packagedetails.PackageDetailsActivity;
import io.github.marktony.espresso.realm.RealmHelper;
import io.github.marktony.espresso.retrofit.RetrofitClient;
import io.github.marktony.espresso.retrofit.RetrofitService;
import io.github.marktony.espresso.util.PushUtils;
Expand All @@ -30,7 +31,6 @@
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import io.realm.Realm;
import io.realm.RealmConfiguration;

import static io.github.marktony.espresso.realm.RealmHelper.DATABASE_NAME;

Expand Down Expand Up @@ -83,10 +83,7 @@ protected void onHandleIntent(@Nullable Intent intent) {
return;
}

Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();

List<Package> results = rlm.copyFromRealm(
rlm.where(Package.class)
Expand All @@ -100,10 +97,7 @@ protected void onHandleIntent(@Nullable Intent intent) {
if (p.isPushable()) {


Realm realm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(DATABASE_NAME)
.build());
Realm realm = RealmHelper.newRealmInstance();

p.setPushable(false);

Expand Down Expand Up @@ -225,10 +219,7 @@ public void accept(Package aPackage) throws Exception {

if (aPackage != null && aPackage.getData().size() > p.getData().size()) {

Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(DATABASE_NAME)
.build());
Realm rlm = RealmHelper.newRealmInstance();

p.setReadable(true);
p.setPushable(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ public class OnboardingActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Set the navigation bar color
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("navigation_bar_tint", true)) {
getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
}

final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
if (sp.getBoolean(SettingsUtils.KEY_FIRST_LAUNCH, true)) {

Expand Down Expand Up @@ -121,6 +116,7 @@ private void initViews() {
viewPager = (ViewPager) findViewById(R.id.container);
viewPager.setAdapter(pagerAdapter);
buttonFinish = (AppCompatButton) 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);
Expand Down Expand Up @@ -148,6 +144,7 @@ private void updateIndicators(int position) {
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_DATA_INSERT_FINISH:
buttonFinish.setText(R.string.onboarding_finish_button_description);
buttonFinish.setEnabled(true);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

switch (page) {
case 0:
sectionImg.setBackgroundResource(R.drawable.ic_flight_black_24dp);
sectionLabel.setText("Section 1");
// set intro
sectionImg.setBackgroundResource(R.drawable.ic_beenhere_black_24dp);
sectionLabel.setText(R.string.onboarding_section_1);
sectionIntro.setText(R.string.onboarding_intro_1);
break;
case 1:
sectionImg.setBackgroundResource(R.drawable.ic_local_shipping_black_24dp);
sectionLabel.setText("Section 2");
sectionImg.setBackgroundResource(R.drawable.ic_notifications_black_24dp);
sectionLabel.setText(R.string.onboarding_section_2);
sectionIntro.setText(R.string.onboarding_intro_2);
break;
case 2:
sectionImg.setBackgroundResource(R.drawable.ic_watch_black_24dp);
sectionLabel.setText("Section 3");
sectionLabel.setText(R.string.onboarding_section_3);
sectionIntro.setText(R.string.onboarding_intro_3);
break;
default:
break;
Expand Down
Loading

0 comments on commit 7815734

Please sign in to comment.