Преглед на файлове

Merge branch 'develop' of https://github.com/swict/LifePlusAndroid into develop

hyodong.min преди 7 години
родител
ревизия
7bcc0bfd48

+ 7 - 2
app/src/main/AndroidManifest.xml

@@ -6,7 +6,8 @@
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
-
+  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
   <application
     android:name=".lifeplus.application.App"
     android:allowBackup="true"
@@ -27,7 +28,11 @@
         <category android:name="android.intent.category.LAUNCHER"/>
       </intent-filter>
     </activity>
-
+    <activity
+      android:name=".lifeplus.activity.LocationActivity"
+      android:screenOrientation="portrait"
+      android:windowSoftInputMode="adjustResize">
+    </activity>
     <activity
       android:name=".lifeplus.activity.MainActivity"
       android:screenOrientation="portrait"

+ 158 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/activity/LocationActivity.java

@@ -0,0 +1,158 @@
+package kr.co.zumo.app.lifeplus.activity;
+
+import android.Manifest;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.location.Address;
+import android.location.Geocoder;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v4.app.ActivityCompat;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.widget.Toast;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * TestActivity
+ * <pre>
+ * </pre>
+ *
+ * @author 하세미
+ * @version 1.0
+ * @history 하세미   [2018-11-06]   [최초 작성]
+ * @since 2018-11-06
+ */
+public class LocationActivity extends AppCompatActivity{
+
+  private final int REQUEST_CODE_PERMISSIONS=1000;
+  private LocationManager locationManager;
+  private LocationListener locationListener;
+
+  private boolean isGPSEnabled;
+  private boolean isNetworkEnabled;
+  private double latitude;
+  private double longitude;
+
+
+  @Override
+  protected void onCreate(@Nullable Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+    setting();
+    getLocation();
+
+  }
+
+
+  private void setting() {
+    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
+    isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
+    isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+    Log.e("APP#  LocationActivity | onCreate", "|" + isGPSEnabled + ", " + isNetworkEnabled);
+
+    locationListener = new LocationListener() {
+      @Override
+      public void onLocationChanged(Location location) {
+        latitude = location.getLatitude();
+        longitude = location.getLongitude();
+        Log.e("APP#  LocationActivity | onLocationChanged", "|" + latitude + ", " + longitude);
+        String address = getAddress(latitude, longitude);
+        Log.e("APP#  LocationActivity | onLocationChanged", "|" + address);
+      }
+
+      @Override
+      public void onStatusChanged(String s, int i, Bundle bundle) {
+      }
+
+      @Override
+      public void onProviderEnabled(String s) {
+      }
+
+      @Override
+      public void onProviderDisabled(String s) {
+
+      }
+    };
+
+    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+      return;
+    }
+
+  }
+
+  @Override
+  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+    switch (requestCode) {
+      case REQUEST_CODE_PERMISSIONS:
+        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+          Toast.makeText(this, "권한 체크 거부됨", Toast.LENGTH_SHORT).show();
+        }
+        break;
+      default:
+        break;
+    }
+  }
+
+  private void getLocation() {
+
+    Location location = null;
+
+    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+      return;
+    }
+    if (isNetworkEnabled) {
+      locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 100, 1, locationListener);
+      if (null != locationManager) {
+        location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+        if (null != location) {
+          Log.e("APP#  LocationActivity | getLocation", "|" + location.getLatitude() + ", " + location.getLongitude());
+        }
+      }
+
+    }
+
+    if (isGPSEnabled) {
+      if (location == null) {
+        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 1, locationListener);
+        if (null != locationManager) {
+          location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
+          if (null != location) {
+            Log.e("APP#  LocationActivity | getLocation", "|vv" + location.getLongitude() + ", " + location.getLatitude());
+          }
+        }
+      }
+    }
+  }
+
+
+  private String getAddress(double latitude, double longitude){
+
+    String nowAddress ="none";
+    Geocoder geocoder = new Geocoder(this, Locale.KOREA);
+    List<Address> addressList;
+
+    if(null != geocoder){
+      try {
+        addressList = geocoder.getFromLocation(latitude, longitude, 1);
+        if(addressList != null && addressList.size() > 0){
+          String currentAddress = addressList.get(0).getAddressLine(0).toString();
+          nowAddress = currentAddress;
+       
+        }
+      } catch (IOException e) {
+        e.printStackTrace();
+      }
+    }
+    return nowAddress;
+  }
+
+}

+ 11 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/bean/FilterBean.java

@@ -20,10 +20,20 @@ public class FilterBean extends JsonBeanBase {
 
   private int categoryId;
   private int checkedIndex;
+  private String checkedValue;
 
-  public FilterBean(int categoryId, int checkedIndex) {
+  public FilterBean(int categoryId, int checkedIndex, String checkedValue) {
     this.categoryId = categoryId;
     this.checkedIndex = checkedIndex;
+    this.checkedValue = checkedValue;
+  }
+
+  public String getCheckedValue() {
+    return checkedValue;
+  }
+
+  public void setCheckedValue(String checkedValue) {
+    this.checkedValue = checkedValue;
   }
 
   public int getCategoryId() {

+ 5 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/CustomSquareCheckBox.java

@@ -81,4 +81,9 @@ public class CustomSquareCheckBox extends ConstraintLayout  {
   public void setChecked(boolean isChecked){
     checkBox.setChecked(isChecked);
   }
+
+  public String getText(){
+    return checkBox.getText().toString();
+  }
+
 }

+ 5 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/dialog/CategoryFirstMainFilterDialog.java

@@ -123,34 +123,34 @@ public class CategoryFirstMainFilterDialog extends DialogBase<ICustomFilterListe
     for (int i = 0; i < firstCategoryCheckboxList.size(); ++i) {
       CustomSquareCheckBox firstCategoryCheckBox = firstCategoryCheckboxList.get(i);
       if (firstCategoryCheckBox.isChecked()) {
-        data.add(new FilterBean(FilterBean.CATEGORY_FIRST_ID, i));
+        data.add(new FilterBean(FilterBean.CATEGORY_FIRST_ID, i, firstCategoryCheckBox.getText()));
       }
     }
 
     for (int i = 0; i < secondCategoryCheckboxList.size(); ++i) {
       CustomSquareCheckBox secondCategoryCheckBox = secondCategoryCheckboxList.get(i);
       if (secondCategoryCheckBox.isChecked()) {
-        data.add(new FilterBean(FilterBean.CATEGORY_SECOND_ID, i));
+        data.add(new FilterBean(FilterBean.CATEGORY_SECOND_ID, i, secondCategoryCheckBox.getText()));
       }
     }
 
     for (int i = 0; i < thirdCategoryCheckBoxList.size(); ++i) {
       CustomSquareCheckBox thirdCategoryCheckBox = thirdCategoryCheckBoxList.get(i);
       if (thirdCategoryCheckBox.isChecked()) {
-        data.add(new FilterBean(FilterBean.CATEGORY_THIRD_ID, i));
+        data.add(new FilterBean(FilterBean.CATEGORY_THIRD_ID, i, thirdCategoryCheckBox.getText()));
       }
     }
 
     for (int i = 0; i < fourthCategoryCheckBoxList.size(); ++i) {
       CustomSquareCheckBox fourthCategoryCheckBox = fourthCategoryCheckBoxList.get(i);
       if (fourthCategoryCheckBox.isChecked()) {
-        data.add(new FilterBean(FilterBean.CATEGORY_FOURTH_ID, i));
+        data.add(new FilterBean(FilterBean.CATEGORY_FOURTH_ID, i, fourthCategoryCheckBox.getText()));
       }
     }
 
     //주차여부
     if (fifthCategoryCheckBox.isChecked()) {
-      data.add(new FilterBean(FilterBean.CATEGORY_FIFTH_ID, 0));
+      data.add(new FilterBean(FilterBean.CATEGORY_FIFTH_ID, 0, fifthCategoryCheckBox.getText()));
     }
   }
 

+ 4 - 4
app/src/main/java/kr/co/zumo/app/lifeplus/view/dialog/CategorySecondMainFilterDialog.java

@@ -110,7 +110,7 @@ public class CategorySecondMainFilterDialog extends DialogBase<ICustomFilterList
     for (int i = 0; i < firstCategoryCheckboxList.size(); ++i) {
       CustomSquareCheckBox firstCategoryCheckBox = firstCategoryCheckboxList.get(i);
       if (firstCategoryCheckBox.isChecked()) {
-        data.add(new FilterBean(FilterBean.CATEGORY_FIRST_ID, i));
+        data.add(new FilterBean(FilterBean.CATEGORY_FIRST_ID, i, firstCategoryCheckBox.getText()));
       }
 
     }
@@ -118,21 +118,21 @@ public class CategorySecondMainFilterDialog extends DialogBase<ICustomFilterList
     for (int i = 0; i < secondCategoryCheckboxList.size(); ++i) {
       CustomSquareCheckBox secondCategoryCheckBox = secondCategoryCheckboxList.get(i);
       if (secondCategoryCheckBox.isChecked()) {
-        data.add(new FilterBean(FilterBean.CATEGORY_SECOND_ID, i));
+        data.add(new FilterBean(FilterBean.CATEGORY_SECOND_ID, i, secondCategoryCheckBox.getText()));
       }
     }
 
     for (int i = 0; i < thirdCategoryCheckBoxList.size(); ++i) {
       CustomSquareCheckBox thirdCategoryCheckBox = thirdCategoryCheckBoxList.get(i);
       if (thirdCategoryCheckBox.isChecked()) {
-        data.add(new FilterBean(FilterBean.CATEGORY_THIRD_ID, i));
+        data.add(new FilterBean(FilterBean.CATEGORY_THIRD_ID, i, thirdCategoryCheckBox.getText()));
       }
     }
 
     for (int i = 0; i < fourthCategoryCheckBoxList.size(); ++i) {
       CustomSquareCheckBox fourthCategoryCheckBox = fourthCategoryCheckBoxList.get(i);
       if (fourthCategoryCheckBox.isChecked()) {
-        data.add(new FilterBean(FilterBean.CATEGORY_FOURTH_ID, i));
+        data.add(new FilterBean(FilterBean.CATEGORY_FOURTH_ID, i, fourthCategoryCheckBox.getText()));
       }
     }
   }

+ 1 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/category/FirstCategoryMainPresenter.java

@@ -113,7 +113,7 @@ public class FirstCategoryMainPresenter extends Presenter<FirstCategoryMainModel
           .listener(new ICustomFilterListener() {
             @Override
             public void onFilterResult(ArrayList<FilterBean> list) {
-              Log.w("APP# FirstCategoryMainPresenter | onFilterResult", "|" + list.size());
+              Log.w("APP# FirstCategoryMainPresenter | onFilterResult", "|" + list.get(0).getCheckedValue());
             }
           })
           .show();

+ 2 - 1
app/src/main/res/layout/fragment_category_main_first.xml

@@ -25,10 +25,11 @@
       android:id="@+id/spinner_select_contents"
       android:layout_width="wrap_content"
       android:layout_height="45dp"
-      android:layout_marginStart="25dp"
+      android:layout_marginStart="14dp"
       android:background="@drawable/filter_drop_down"
       android:entries="@array/main_filter"
       android:focusable="true"
+      android:padding="10dp"
       android:textColor="@color/C000000"
       android:textSize="14sp"/>
 

+ 2 - 1
app/src/main/res/layout/fragment_category_main_fourth.xml

@@ -25,7 +25,8 @@
       android:id="@+id/spinner_select_contents"
       android:layout_width="wrap_content"
       android:layout_height="45dp"
-      android:layout_marginStart="21dp"
+      android:layout_marginStart="11dp"
+      android:padding="10dp"
       android:background="@drawable/filter_drop_down"
       android:entries="@array/main_filter"
       android:focusable="true"

+ 2 - 1
app/src/main/res/layout/fragment_category_main_second.xml

@@ -25,7 +25,8 @@
       android:id="@+id/spinner_select_contents"
       android:layout_width="wrap_content"
       android:layout_height="45dp"
-      android:layout_marginStart="25dp"
+      android:layout_marginStart="15dp"
+      android:padding="10dp"
       android:background="@drawable/filter_drop_down"
       android:entries="@array/main_filter"
       android:focusable="true"

+ 2 - 1
app/src/main/res/layout/fragment_category_main_third.xml

@@ -25,7 +25,8 @@
       android:id="@+id/spinner_select_contents"
       android:layout_width="wrap_content"
       android:layout_height="45dp"
-      android:layout_marginStart="25dp"
+      android:layout_marginStart="15dp"
+      android:padding="10dp"
       android:background="@drawable/filter_drop_down"
       android:entries="@array/main_filter"
       android:focusable="true"

+ 2 - 0
app/src/main/res/layout/fragment_default_book_mark.xml

@@ -8,6 +8,8 @@
 
     <android.support.v7.widget.RecyclerView
       android:id="@+id/recycler_view_default_book_mark"
+      android:layout_marginTop="45dp"
+      app:layout_constraintTop_toTopOf="parent"
       android:layout_width="match_parent"
       android:layout_height="match_parent"/>
   

+ 1 - 1
app/src/main/res/layout/fragment_my_main_guest_case.xml

@@ -159,7 +159,7 @@
       <TextView
         android:id="@+id/text_view_book_mark_recommend"
         android:layout_width="wrap_content"
-        android:layout_height="13dp"
+        android:layout_height="wrap_content"
         android:layout_marginTop="15dp"
         android:gravity="center_horizontal"
         android:lineSpacingExtra="10sp"

+ 1 - 0
app/src/main/res/layout/fragment_my_main_login_case.xml

@@ -310,6 +310,7 @@
         android:layout_marginTop="8dp"
         android:layout_marginEnd="208dp"
         android:layout_marginBottom="16dp"
+        android:visibility="gone"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintHorizontal_bias="1.0"
         app:layout_constraintStart_toEndOf="@+id/image_view_book_mark"

+ 1 - 1
app/src/main/res/layout/main_first_category_banner_view.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.constraint.ConstraintLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
-  android:layout_width="wrap_content"
+  android:layout_width="match_parent"
   android:layout_height="wrap_content">
 
 <kr.co.zumo.app.lifeplus.view.custom.main.banner.MainBannerView