update step count setup.
authorTrillGates <williamtrillgates@gmail.com>
Fri, 27 Aug 2021 02:51:06 +0000 (10:51 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Fri, 27 Aug 2021 02:51:06 +0000 (10:51 +0800)
12 files changed:
app/src/main/java/com/ic/sport/PedometerActivity.java
app/src/main/java/com/ic/sport/adapter/PedSetupAdapter.java
app/src/main/java/com/ic/sport/fragment/pedometer/PedSetupDialogFragment.java
app/src/main/java/com/ic/sport/fragment/pedometer/PedSetupFragment.java
app/src/main/java/com/ic/sport/model/PedometerModel.java
app/src/main/java/com/ic/sport/presenter/PedometerPresenter.java
app/src/main/java/com/ic/sport/util/SPUtils.java
app/src/main/res/layout/dialog_ped_setup_layout.xml
app/src/main/res/values-en/strings.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values-zh/strings.xml
app/src/main/res/values/strings.xml

index b1ab4d3..b830e2d 100644 (file)
@@ -99,7 +99,7 @@ public class PedometerActivity extends AppCompatActivity
 
     @Override
     public void onDialogUpdate(int type, int value) {
-        ((PedSetupFragment) myAdapter.getFragment(0)).updateSetuUpValue(type, value);
+        ((PedSetupFragment) myAdapter.getFragment(0)).updateSetUpValue(type, value);
         switch (type) {
             case 0:
                 pedometerModel.syncPedHeightSetting(value);
@@ -107,8 +107,11 @@ public class PedometerActivity extends AppCompatActivity
                 break;
             case 1:
                 pedometerModel.syncPedWeightSetting(value);
-                SPUtils.setPedWighttSP(getApplicationContext(), value);
+                SPUtils.setPedWightSP(getApplicationContext(), value);
                 break;
+            case 2:
+                //不需要通知远程服务
+                SPUtils.setPedTargetSP(getApplicationContext(), value);
         }
     }
 
index 5be3b0b..2793958 100644 (file)
@@ -43,7 +43,7 @@ public class PedSetupAdapter extends RecyclerView.Adapter<PedSetupAdapter.SetUpH
         setupArray = new PedSetupEntity[3];
         int[] valueArray = new int[]{
                 SPUtils.getPedHeightSP(context),
-                SPUtils.getPedWighttSP(context),
+                SPUtils.getPedWeightSP(context),
                 SPUtils.getPedTargetSP(context)
         };
 
index 2227247..6514661 100644 (file)
@@ -8,7 +8,6 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.Window;
-import android.widget.ImageButton;
 import android.widget.ImageView;
 
 import androidx.annotation.NonNull;
@@ -16,6 +15,7 @@ import androidx.annotation.Nullable;
 import androidx.collection.ArrayMap;
 import androidx.fragment.app.DialogFragment;
 
+import com.ic.iclooger.ICLogger;
 import com.ic.sport.R;
 import com.ic.sport.util.SPUtils;
 import com.ic.sport.widget.picker.NumericWheelAdapter;
@@ -42,8 +42,8 @@ public class PedSetupDialogFragment extends DialogFragment {
 
     private final ArrayMap<Integer, int[]> limil = new ArrayMap<>();
 
-    private final String[] UNIT_RES = new String[2];
-    private final int[] VALUE_CURR = new int[2];
+    private final String[] UNIT_RES = new String[3];
+    private final int[] VALUE_CURR = new int[3];
 
     private NoticeDialogListener mListener;
 
@@ -66,13 +66,20 @@ public class PedSetupDialogFragment extends DialogFragment {
         }
 
         VALUE_CURR[0] = SPUtils.getPedHeightSP(mContext);
-        VALUE_CURR[1] = SPUtils.getPedWighttSP(mContext);
+        VALUE_CURR[1] = SPUtils.getPedWeightSP(mContext);
+        VALUE_CURR[2] = SPUtils.getPedTargetSP(mContext);
+
+        ICLogger.d("height value ==> " + VALUE_CURR[0]);
+        ICLogger.d("weight value ==> " + VALUE_CURR[0]);
+        ICLogger.d("petTarget value ==> " + VALUE_CURR[0]);
 
         UNIT_RES[0] = getString(R.string.tips_height_unit);
         UNIT_RES[1] = getString(R.string.tips_weight_unit);
+        UNIT_RES[2] = getString(R.string.step_unit);
 
         limil.put(0, new int[]{30, 250});
         limil.put(1, new int[]{15, 150});
+        limil.put(2, new int[]{3000, 50000});
     }
 
     @Override
@@ -85,20 +92,20 @@ public class PedSetupDialogFragment extends DialogFragment {
         }
 
         View popView = inflater.inflate(R.layout.dialog_ped_setup_layout, container);
-        numberPicker = (WheelView) popView.findViewById(R.id.dialog_value_picker);
+        numberPicker = popView.findViewById(R.id.dialog_value_picker);
         setNumberPicker(limil.get(mCurrType)[0],
                 limil.get(mCurrType)[1],
                 UNIT_RES[mCurrType],
                 VALUE_CURR[mCurrType]);
 
-        ImageView bt = (ImageView) popView.findViewById(R.id.dialog_picker_ok);
+        ImageView bt = popView.findViewById(R.id.dialog_picker_ok);
         bt.setOnClickListener(v -> {
-            mListener.onDialogUpdate(mCurrType,limil.get(mCurrType)[0]+numberPicker.getCurrentItem());
+            mListener.onDialogUpdate(mCurrType,
+                    limil.get(mCurrType)[0] + numberPicker.getCurrentItem());
             dismiss();
         });
-        ImageView cancel = (ImageView) popView.findViewById(R.id.dialog_picker_cancel);
+        ImageView cancel = popView.findViewById(R.id.dialog_picker_cancel);
         cancel.setOnClickListener(v -> dismiss());
-
         return popView;
     }
 
@@ -106,9 +113,13 @@ public class PedSetupDialogFragment extends DialogFragment {
         numberPicker.setAdapter(new NumericWheelAdapter(numberMin, numberMax));
         numberPicker.setLabel(label);
         numberPicker.setCyclic(true);
-        numberPicker.TEXT_SIZE = (int) spToPx(65);
-        numberPicker.ITEM_TEXT_SIZE = (int) spToPx(42);
-
+        if (mCurrType == 2) {
+            numberPicker.TEXT_SIZE = (int) spToPx(42);
+            numberPicker.ITEM_TEXT_SIZE = (int) spToPx(32);
+        } else {
+            numberPicker.TEXT_SIZE = (int) spToPx(65);
+            numberPicker.ITEM_TEXT_SIZE = (int) spToPx(42);
+        }
         numberPicker.setCurrentItem(numberDefault - numberMin);
     }
 
index 04450b7..0e65f17 100644 (file)
@@ -3,6 +3,9 @@ package com.ic.sport.fragment.pedometer;
 import android.content.Context;
 import android.graphics.Rect;
 import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
 
 import androidx.annotation.NonNull;
 import androidx.fragment.app.Fragment;
@@ -10,10 +13,6 @@ import androidx.fragment.app.FragmentManager;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
 import com.ic.sport.R;
 import com.ic.sport.adapter.PedSetupAdapter;
 
@@ -78,16 +77,13 @@ public class PedSetupFragment extends Fragment {
         mSetupRv.setAdapter(setupAdapter);
     }
 
-    private OnPedSetupItemClickListener listener = pos -> {
-        if (pos == 2) {
-            return;
-        }
+    private final OnPedSetupItemClickListener listener = pos -> {
         FragmentManager fm = getChildFragmentManager();
         PedSetupDialogFragment alertDialog = PedSetupDialogFragment.newInstance(pos);
         alertDialog.show(fm, "PedSetupDialog");
     };
 
-    public void updateSetuUpValue(int type, int value) {
+    public void updateSetUpValue(int type, int value) {
         setupAdapter.notifyUpdateValue(type, value);
     }
 
index 338561a..854f9af 100644 (file)
@@ -111,7 +111,6 @@ public class PedometerModel extends AndroidViewModel {
     public void syncPedWeightSetting(int weight) {
         pedometerPresenter.syncPedWeightSetting(weight);
     }
-
     public static class Factory extends ViewModelProvider.NewInstanceFactory {
 
         @NonNull
index 11f03f6..086ffc2 100644 (file)
@@ -4,7 +4,6 @@ import android.content.ComponentName;
 import android.content.Context;
 import android.content.ServiceConnection;
 import android.os.IBinder;
-import android.os.RemoteException;
 
 import androidx.lifecycle.LiveData;
 import androidx.lifecycle.MutableLiveData;
@@ -15,7 +14,6 @@ import com.ic.aidl.ped.RecordParcelable;
 import com.ic.sport.util.IcLog;
 import com.ic.sport.util.ServiceUtil;
 
-import java.net.FileNameMap;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
index 9f3a6ce..b5e0bd6 100644 (file)
@@ -18,7 +18,7 @@ public class SPUtils {
         return getSp(context).getInt(Ped_Height, 170);
     }
 
-    public static int getPedWighttSP(Context context) {
+    public static int getPedWeightSP(Context context) {
         return getSp(context).getInt(Ped_Weight, 75);
     }
 
@@ -34,7 +34,7 @@ public class SPUtils {
         }
     }
 
-    public static void setPedWighttSP(Context context,int weight) {
+    public static void setPedWightSP(Context context, int weight) {
         SharedPreferences.Editor editor = getSp(context).edit();
         if (editor != null) {
             editor.putInt(Ped_Weight, weight);
index c7f2ecd..b8a9697 100644 (file)
@@ -15,7 +15,7 @@
             android:layout_width="match_parent"
             android:layout_height="260dp"
             android:layout_gravity="center"
-            android:layout_marginLeft="26dp" />
+            android:layout_marginLeft="60dp" />
     </LinearLayout>
 
 
@@ -27,8 +27,8 @@
 
         <ImageView
             android:id="@+id/dialog_picker_cancel"
-            android:layout_width="80dp"
-            android:layout_height="80dp"
+            android:layout_width="100dp"
+            android:layout_height="100dp"
             android:layout_gravity="bottom"
             android:background="@color/transparent"
             android:contentDescription="@null"
@@ -36,8 +36,8 @@
 
         <ImageView
             android:id="@+id/dialog_picker_ok"
-            android:layout_width="80dp"
-            android:layout_height="80dp"
+            android:layout_width="100dp"
+            android:layout_height="100dp"
             android:layout_alignParentEnd="true"
             android:layout_gravity="bottom|end"
             android:background="@color/transparent"
index 507b165..8a49b7a 100644 (file)
@@ -44,4 +44,5 @@
     <string name="pedometer_unit_foot">feet</string>
     <string name="reached_step_goal">completed</string>
     <string name="target_text">aim:</string>
+    <string name="step_unit">step</string>
 </resources>
index 658a251..0e9c428 100644 (file)
@@ -43,5 +43,6 @@
     <string name="pedometer_unit_foot">英尺</string>
     <string name="reached_step_goal">已达到目标步数</string>
     <string name="target_text">目標:</string>
+    <string name="step_unit">step</string>
 
 </resources>
index a0b5710..57ed0ec 100644 (file)
@@ -44,4 +44,5 @@
     <string name="pedometer_unit_foot">英尺</string>
     <string name="reached_step_goal">已达到目标步数</string>
     <string name="target_text">目标:</string>
+    <string name="step_unit">step</string>
 </resources>
index a0b5710..57ed0ec 100644 (file)
@@ -44,4 +44,5 @@
     <string name="pedometer_unit_foot">英尺</string>
     <string name="reached_step_goal">已达到目标步数</string>
     <string name="target_text">目标:</string>
+    <string name="step_unit">step</string>
 </resources>