diff --git a/.idea/misc.xml b/.idea/misc.xml index 08a11bd..46539ff 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -27,34 +27,6 @@ - - - - - - - - - Android > Lint > Correctness - - - Java - - - Probable bugsJava - - - RELAX NG - - - - - Android - - - - - diff --git a/mobile/build.gradle b/mobile/build.gradle index 5f7ef61..aa6dbbd 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -40,12 +40,12 @@ dependencies { // Google Mobile Service compile 'com.google.android.gms:play-services:10.2.1' // Support libraries - compile 'com.android.support:appcompat-v7:25.3.0' - compile 'com.android.support:support-v4:25.3.0' - compile 'com.android.support:design:25.3.0' - compile 'com.android.support:cardview-v7:25.3.0' - compile 'com.android.support:preference-v14:25.3.0' - compile 'com.android.support:customtabs:25.3.0' + compile 'com.android.support:appcompat-v7:25.3.1' + compile 'com.android.support:support-v4:25.3.1' + compile 'com.android.support:design:25.3.1' + compile 'com.android.support:cardview-v7:25.3.1' + compile 'com.android.support:preference-v14:25.3.1' + compile 'com.android.support:customtabs:25.3.1' // ReactiveX series compile 'io.reactivex.rxjava2:rxjava:2.0.1' compile 'io.reactivex.rxjava2:rxandroid:2.0.1' diff --git a/mobile/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageFragment.java b/mobile/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageFragment.java index 3abacf1..d91bb9d 100644 --- a/mobile/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageFragment.java +++ b/mobile/src/main/java/io/github/marktony/espresso/mvp/addpackage/AddPackageFragment.java @@ -23,7 +23,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; -import android.graphics.Rect; import android.net.Uri; import android.os.Bundle; import android.provider.Settings; @@ -34,7 +33,6 @@ import android.support.design.widget.TextInputEditText; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; -import android.support.v4.widget.NestedScrollView; import android.support.v7.app.AlertDialog; import android.support.v7.widget.AppCompatTextView; import android.support.v7.widget.Toolbar; @@ -42,7 +40,6 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.view.ViewTreeObserver; import android.view.inputmethod.InputMethodManager; import android.widget.ProgressBar; @@ -70,7 +67,6 @@ public class AddPackageFragment extends Fragment private AppCompatTextView textViewScanCode; private FloatingActionButton fab; private ProgressBar progressBar; - private NestedScrollView scrollView; private AddPackageContract.Presenter presenter; @@ -99,8 +95,6 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, initViews(view); - addLayoutListener(scrollView, editTextName); - fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -166,32 +160,6 @@ public void onPause() { presenter.unsubscribe(); } - /** - * Scroll the screen to avoid edit text being covered by imm such as the soft keyboard. - * It is better to set the height as 150 because some devices - * has the navigation bar. The height 100 might not trigger the scrolling action. - * @param main The scroll view. - * @param scroll The view to show. - */ - private void addLayoutListener(final View main, final View scroll) { - main.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - Rect rect = new Rect(); - main.getWindowVisibleDisplayFrame(rect); - int mainInvisibleHeight = main.getRootView().getHeight() - rect.bottom; - if (mainInvisibleHeight > 150) { - int[] location = new int[2]; - scroll.getLocationInWindow(location); - int scrollHeight = (location[1] + scroll.getHeight()) - rect.bottom; - main.scrollTo(0, scrollHeight); - } else { - main.scrollTo(0, 0); - } - } - }); - } - @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); @@ -217,8 +185,6 @@ public void initViews(View view) { 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); - } /** diff --git a/mobile/src/main/res/layout/fragment_add_package.xml b/mobile/src/main/res/layout/fragment_add_package.xml index 395d5c4..61a16d9 100644 --- a/mobile/src/main/res/layout/fragment_add_package.xml +++ b/mobile/src/main/res/layout/fragment_add_package.xml @@ -53,26 +53,26 @@ - + android:layout_height="wrap_content" + android:id="@+id/scrollView" + android:scrollbars="vertical" + android:scrollbarFadeDuration="1" + app:layout_behavior="@string/appbar_scrolling_view_behavior" + android:fadeScrollbars="true"> - + android:layout_height="match_parent"> - + - + - + diff --git a/wear/build.gradle b/wear/build.gradle index ca4f20a..91c6957 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -21,5 +21,5 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.android.support:wearable:2.0.0' - compile 'com.google.android.gms:play-services-wearable:10.2.0' + compile 'com.google.android.gms:play-services-wearable:10.2.1' } diff --git a/wear/src/main/java/io/github/marktony/espresso/MainActivity.java b/wear/src/main/java/io/github/marktony/espresso/MainActivity.java index 6347a38..9ac4918 100644 --- a/wear/src/main/java/io/github/marktony/espresso/MainActivity.java +++ b/wear/src/main/java/io/github/marktony/espresso/MainActivity.java @@ -18,23 +18,37 @@ import android.app.Activity; import android.os.Bundle; -import android.support.wearable.view.WatchViewStub; -import android.widget.TextView; +import android.support.wearable.view.DefaultOffsettingHelper; +import android.support.wearable.view.WearableRecyclerView; -public class MainActivity extends Activity { +import java.util.ArrayList; +import java.util.List; + +import io.github.marktony.espresso.data.Package; - private TextView mTextView; +public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); - stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { - @Override - public void onLayoutInflated(WatchViewStub stub) { - mTextView = (TextView) stub.findViewById(R.id.text); - } - }); + + List list = new ArrayList<>(); + Package p1 = new Package(); + p1.setName("SF"); + list.add(p1); + + Package p2 = new Package(); + p2.setName("YUNDA"); + list.add(p2); + + WearableRecyclerView recyclerView = (WearableRecyclerView) findViewById(R.id.recyclerView); + recyclerView.setCenterEdgeItems(true); + + recyclerView.setOffsettingHelper(new DefaultOffsettingHelper()); + + PackageRecyclerAdapter adapter = new PackageRecyclerAdapter(list); + recyclerView.setAdapter(adapter); + } } diff --git a/wear/src/main/java/io/github/marktony/espresso/PackageRecyclerAdapter.java b/wear/src/main/java/io/github/marktony/espresso/PackageRecyclerAdapter.java new file mode 100644 index 0000000..1c18e36 --- /dev/null +++ b/wear/src/main/java/io/github/marktony/espresso/PackageRecyclerAdapter.java @@ -0,0 +1,86 @@ +/* + * Copyright(c) 2017 lizhaotailang + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.github.marktony.espresso; + +import android.support.annotation.NonNull; +import android.support.v7.widget.RecyclerView; +import android.support.wearable.view.CircledImageView; +import android.support.wearable.view.WearableRecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import java.util.List; + +import io.github.marktony.espresso.data.Package; + +/** + * Created by lizhaotailang on 2017/3/31. + */ + +public class PackageRecyclerAdapter extends WearableRecyclerView.Adapter { + + private final List mList; + + public PackageRecyclerAdapter(@NonNull List list) { + mList = list; + } + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + return new ViewHolder(LayoutInflater.from(parent.getContext()) + .inflate(R.layout.item_package, parent, false)); + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { + Package p = mList.get(position); + ViewHolder vh = (ViewHolder) holder; + if (p != null) { + vh.textViewAvatar.setText(p.getName().substring(0, 1)); + vh.textViewName.setText(p.getName()); + if (p.getData() != null && p.getData().size() > 0) { + vh.textViewStatus.setText(p.getData().get(0).getContext()); + } else { + vh.textViewStatus.setText("Can not get the latest status."); + } + } + } + + @Override + public int getItemCount() { + return mList.size(); + } + + public class ViewHolder extends WearableRecyclerView.ViewHolder { + + private TextView textViewAvatar; + private TextView textViewName; + private TextView textViewStatus; + private CircledImageView avatar; + + public ViewHolder(View itemView) { + super(itemView); + textViewAvatar = (TextView) itemView.findViewById(R.id.textViewAvatar); + textViewName = (TextView) itemView.findViewById(R.id.textViewName); + textViewStatus = (TextView) itemView.findViewById(R.id.textViewStatus); + avatar = (CircledImageView) itemView.findViewById(R.id.avatar); + } + } + +} diff --git a/wear/src/main/java/io/github/marktony/espresso/data/Package.java b/wear/src/main/java/io/github/marktony/espresso/data/Package.java new file mode 100644 index 0000000..2f7b4b9 --- /dev/null +++ b/wear/src/main/java/io/github/marktony/espresso/data/Package.java @@ -0,0 +1,212 @@ +/* + * Copyright(c) 2017 lizhaotailang + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.github.marktony.espresso.data; + +import java.util.List; + +/** + * Created by lizhaotailang on 2017/2/10. + * Immutable model class for a Package. + * 示例JSON格式 + * JSON format sample + * { + * "message":"ok", + * "nu":"47258833029", + * "ischeck":"1", + * "condition":"F00", + * "com":"jd", + * "status":"200", + * "state":"3", + * "data": + * [ + * { + * "time":"2016-12-13 21:35:51", + * "ftime":"2016-12-13 21:35:51", + * "context":"货物已完成配送,感谢您选择京东配送", + * "location":"" + * }, + * { + * "time":"2016-12-13 11:01:55", + * "ftime":"2016-12-13 11:01:55", + * "context":"配送员开始配送,请您准备收货,配送员,朱小宝,手机号,13060495388或0917-2622505", + * "location":"" + * }, + * { + * "time":"2016-12-13 10:06:25", + * "ftime":"2016-12-13 10:06:25", + * "context":"货物已分配,等待配送", + * "location":"" + * }, + * { + * "time":"2016-12-13 10:06:22", + * "ftime":"2016-12-13 10:06:22", + * "context":"货物已到达【宝鸡北环站】","location":"" + * }, + * ... + * ] + * } + */ + +public class Package { + + public static final int STATUS_FAILED = 2, STATUS_NORMAL = 0, + STATUS_ON_THE_WAY = 5, STATUS_DELIVERED = 3, + STATUS_RETURNED = 4, STATUS_RETURNING = 6, + STATUS_OTHER = 1; + + private String message; + + private String number; + + private String isCheck; + + private String condition; + + private String company; + + private String status; + + private String state; + + private List data; + + + private boolean pushable = false; + + private boolean readable = false; + + private String name; + + private String companyChineseName; + + private int colorAvatar; + + private long timestamp; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public String getIsCheck() { + return isCheck; + } + + public void setIsCheck(String isCheck) { + this.isCheck = isCheck; + } + + public String getCondition() { + return condition; + } + + public void setCondition(String condition) { + this.condition = condition; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public boolean isReadable() { + return readable; + } + + public void setReadable(boolean readable) { + this.readable = readable; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + public boolean isPushable() { + return pushable; + } + + public void setPushable(boolean pushable) { + this.pushable = pushable; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCompanyChineseName() { + return companyChineseName; + } + + public void setCompanyChineseName(String companyChineseName) { + this.companyChineseName = companyChineseName; + } + + public void setColorAvatar(int colorAvatar) { + this.colorAvatar = colorAvatar; + } + + public int getColorAvatar() { + return colorAvatar; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public long getTimestamp() { + return timestamp; + } + +} diff --git a/wear/src/main/java/io/github/marktony/espresso/data/PackageStatus.java b/wear/src/main/java/io/github/marktony/espresso/data/PackageStatus.java new file mode 100644 index 0000000..d8027d3 --- /dev/null +++ b/wear/src/main/java/io/github/marktony/espresso/data/PackageStatus.java @@ -0,0 +1,74 @@ +/* + * Copyright(c) 2017 lizhaotailang + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.github.marktony.espresso.data; + +/** + * Created by lizhaotailang on 2017/2/24. + * Immutable model class for a PackageStatus. + */ +public class PackageStatus { + + private String time; + + private String ftime; + + private String context; + + private String location; + + private String phone; + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getFtime() { + return ftime; + } + + public void setFtime(String ftime) { + this.ftime = ftime; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPhone() { + return phone; + } +} diff --git a/wear/src/main/res/layout/activity_main.xml b/wear/src/main/res/layout/activity_main.xml index f7183b3..739dbc8 100644 --- a/wear/src/main/res/layout/activity_main.xml +++ b/wear/src/main/res/layout/activity_main.xml @@ -15,15 +15,14 @@ ~ limitations under the License. --> - - - + android:scrollbars="vertical" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" /> diff --git a/wear/src/main/res/layout/item_package.xml b/wear/src/main/res/layout/item_package.xml new file mode 100644 index 0000000..1941576 --- /dev/null +++ b/wear/src/main/res/layout/item_package.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/wear/src/main/res/layout/round_activity_main.xml b/wear/src/main/res/layout/round_activity_main.xml deleted file mode 100644 index 8ae7b14..0000000 --- a/wear/src/main/res/layout/round_activity_main.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - diff --git a/wear/src/main/res/mipmap-hdpi/ic_launcher.png b/wear/src/main/res/mipmap-hdpi/ic_launcher.png old mode 100644 new mode 100755 index cde69bc..8d3d04d Binary files a/wear/src/main/res/mipmap-hdpi/ic_launcher.png and b/wear/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/wear/src/main/res/mipmap-mdpi/ic_launcher.png b/wear/src/main/res/mipmap-mdpi/ic_launcher.png old mode 100644 new mode 100755 index c133a0c..381ddc9 Binary files a/wear/src/main/res/mipmap-mdpi/ic_launcher.png and b/wear/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/wear/src/main/res/mipmap-xhdpi/ic_launcher.png b/wear/src/main/res/mipmap-xhdpi/ic_launcher.png old mode 100644 new mode 100755 index bfa42f0..b5330b3 Binary files a/wear/src/main/res/mipmap-xhdpi/ic_launcher.png and b/wear/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/wear/src/main/res/mipmap-xxhdpi/ic_launcher.png b/wear/src/main/res/mipmap-xxhdpi/ic_launcher.png old mode 100644 new mode 100755 index 324e72c..e61488b Binary files a/wear/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/wear/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/wear/src/main/res/layout/rect_activity_main.xml b/wear/src/main/res/values/dimens.xml similarity index 56% rename from wear/src/main/res/layout/rect_activity_main.xml rename to wear/src/main/res/values/dimens.xml index 2ab6b37..be29994 100644 --- a/wear/src/main/res/layout/rect_activity_main.xml +++ b/wear/src/main/res/values/dimens.xml @@ -15,17 +15,9 @@ ~ limitations under the License. --> - + - - + 8dp + 8dp + + \ No newline at end of file