Jelajahi Sumber

Added camera and call dialer button

sduduzog 7 tahun lalu
induk
melakukan
e330d1e0d1

+ 3 - 3
app/build.gradle

@@ -10,10 +10,10 @@ android {
         applicationId "com.sduduzog.slimlauncher"
         minSdkVersion 15
         targetSdkVersion 28
-        versionCode 7
-        versionName "1.1.2"
+        versionCode 8
+        versionName "1.2.0"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
-        versionNameSuffix '-bleeding-edge'
+        versionNameSuffix '-preview'
         vectorDrawables.useSupportLibrary = true
     }
     buildTypes {

+ 0 - 15
app/src/main/java/com/sduduzog/slimlauncher/ui/apps/WhyQuestionDialog.kt

@@ -1,15 +0,0 @@
-package com.sduduzog.slimlauncher.ui.apps
-
-import android.app.Dialog
-import android.os.Bundle
-import android.support.v4.app.DialogFragment
-import android.support.v7.app.AlertDialog
-
-class WhyQuestionDialog : DialogFragment(){
-    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
-        val builder = AlertDialog.Builder(context!!)
-        builder.setTitle("Why?")
-        builder.setMessage("That's the point exactly!, this app is supposed to help you use less of your phone.")
-        return builder.create()
-    }
-}

+ 1 - 1
app/src/main/java/com/sduduzog/slimlauncher/ui/apps/AppsFragment.kt → app/src/main/java/com/sduduzog/slimlauncher/ui/main/AppsFragment.kt

@@ -1,4 +1,4 @@
-package com.sduduzog.slimlauncher.ui.apps
+package com.sduduzog.slimlauncher.ui.main
 
 import android.arch.lifecycle.Observer
 import android.arch.lifecycle.ViewModelProviders

+ 2 - 2
app/src/main/java/com/sduduzog/slimlauncher/ui/apps/AppsListAdapter.kt → app/src/main/java/com/sduduzog/slimlauncher/ui/main/AppsListAdapter.kt

@@ -1,4 +1,4 @@
-package com.sduduzog.slimlauncher.ui.apps
+package com.sduduzog.slimlauncher.ui.main
 
 import android.support.v7.widget.RecyclerView
 import android.view.LayoutInflater
@@ -9,7 +9,7 @@ import com.sduduzog.slimlauncher.R
 import com.sduduzog.slimlauncher.data.App
 
 
-import com.sduduzog.slimlauncher.ui.apps.AppsFragment.OnListFragmentInteractionListener
+import com.sduduzog.slimlauncher.ui.main.AppsFragment.OnListFragmentInteractionListener
 
 import kotlinx.android.synthetic.main.apps_list_item.view.*
 

+ 21 - 1
app/src/main/java/com/sduduzog/slimlauncher/ui/main/MainFragment.kt

@@ -7,6 +7,7 @@ import android.content.*
 import android.net.Uri
 import android.os.Build
 import android.os.Bundle
+import android.provider.MediaStore
 import android.support.design.widget.BottomSheetBehavior
 import android.support.design.widget.BottomSheetBehavior.STATE_COLLAPSED
 import android.support.design.widget.BottomSheetBehavior.STATE_HALF_EXPANDED
@@ -174,7 +175,7 @@ class MainFragment : Fragment() {
             }
         }
         bottomSheet.setOnClickListener {
-            if (sheetBehavior.state == STATE_COLLAPSED) sheetBehavior.state = STATE_HALF_EXPANDED
+
         }
         sheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
             override fun onSlide(p0: View, p1: Float) {
@@ -199,5 +200,24 @@ class MainFragment : Fragment() {
             }
         } else changeLauncherText.visibility = View.INVISIBLE
         aboutText.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_openAboutFragment))
+        ivCall.setOnClickListener {
+            try {
+                val intent = Intent(Intent.ACTION_DIAL)
+                startActivity(intent)
+            } catch (e: Exception) {
+                Log.e(TAG, e.message)
+            }
+        }
+        ivCamera.setOnClickListener {
+            try {
+                val intent = Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA)
+                startActivity(intent)
+            } catch (e: Exception) {
+                Log.e(TAG, e.message)
+            }
+        }
+        ivExpand.setOnClickListener {
+            if (sheetBehavior.state == STATE_COLLAPSED) sheetBehavior.state = STATE_HALF_EXPANDED
+        }
     }
 }

+ 1 - 1
app/src/main/java/com/sduduzog/slimlauncher/ui/apps/SettingsFragment.kt → app/src/main/java/com/sduduzog/slimlauncher/ui/main/SettingsFragment.kt

@@ -1,4 +1,4 @@
-package com.sduduzog.slimlauncher.ui.apps
+package com.sduduzog.slimlauncher.ui.main
 
 
 import android.arch.lifecycle.Observer

+ 1 - 1
app/src/main/java/com/sduduzog/slimlauncher/ui/apps/SettingsListAdapter.kt → app/src/main/java/com/sduduzog/slimlauncher/ui/main/SettingsListAdapter.kt

@@ -1,4 +1,4 @@
-package com.sduduzog.slimlauncher.ui.apps
+package com.sduduzog.slimlauncher.ui.main
 
 import android.support.v7.widget.RecyclerView
 import android.view.LayoutInflater

+ 9 - 0
app/src/main/res/drawable-v21/ic_call.xml

@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="?android:colorForeground"
+        android:pathData="M6.62,10.79c1.44,2.83 3.76,5.14 6.59,6.59l2.2,-2.2c0.27,-0.27 0.67,-0.36 1.02,-0.24 1.12,0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1V20c0,0.55 -0.45,1 -1,1 -9.39,0 -17,-7.61 -17,-17 0,-0.55 0.45,-1 1,-1h3.5c0.55,0 1,0.45 1,1 0,1.25 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z" />
+</vector>

+ 12 - 0
app/src/main/res/drawable-v21/ic_photo_camera.xml

@@ -0,0 +1,12 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="?android:colorForeground"
+        android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
+    <path
+        android:fillColor="?android:colorForeground"
+        android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" />
+</vector>

+ 9 - 0
app/src/main/res/drawable/ic_call.xml

@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="@color/colorAccent"
+        android:pathData="M6.62,10.79c1.44,2.83 3.76,5.14 6.59,6.59l2.2,-2.2c0.27,-0.27 0.67,-0.36 1.02,-0.24 1.12,0.37 2.33,0.57 3.57,0.57 0.55,0 1,0.45 1,1V20c0,0.55 -0.45,1 -1,1 -9.39,0 -17,-7.61 -17,-17 0,-0.55 0.45,-1 1,-1h3.5c0.55,0 1,0.45 1,1 0,1.25 0.2,2.45 0.57,3.57 0.11,0.35 0.03,0.74 -0.25,1.02l-2.2,2.2z" />
+</vector>

+ 2 - 2
app/src/main/res/drawable/ic_expand.xml

@@ -1,6 +1,6 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="50dp"
-    android:height="50dp"
+    android:width="24dp"
+    android:height="24dp"
     android:viewportWidth="24.0"
     android:viewportHeight="24.0">
     <path

+ 12 - 0
app/src/main/res/drawable/ic_photo_camera.xml

@@ -0,0 +1,12 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="@color/colorAccent"
+        android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
+    <path
+        android:fillColor="@color/colorAccent"
+        android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" />
+</vector>

+ 88 - 0
app/src/main/res/layout-sw600dp/main_content.xml

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/main_content"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <TextView
+        android:id="@+id/clockTextView"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="32dp"
+        android:text="@string/main_placeholder_clock"
+        android:textSize="64sp"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/dateTextView"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/main_placeholder_date"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/clockTextView" />
+
+    <android.support.v7.widget.RecyclerView
+        android:id="@+id/mainAppsList"
+        android:layout_width="0dp"
+        android:layout_height="500dp"
+        android:layout_marginStart="32dp"
+        android:layout_marginLeft="32dp"
+        android:layout_marginTop="32dp"
+        android:layout_marginEnd="32dp"
+        android:layout_marginRight="32dp"
+        android:layout_marginBottom="32dp"
+        app:layoutManager="android.support.v7.widget.LinearLayoutManager"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/dateTextView"
+        tools:listitem="@layout/main_list_item" />
+
+    <ImageView
+        android:id="@+id/ivExpand"
+        android:layout_width="50dp"
+        android:layout_height="50dp"
+        android:layout_marginStart="8dp"
+        android:layout_marginLeft="8dp"
+        android:layout_marginEnd="8dp"
+        android:layout_marginRight="8dp"
+        android:layout_marginBottom="8dp"
+        android:contentDescription="@string/content_description_expand_up"
+        android:padding="8dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:srcCompat="@drawable/ic_expand" />
+
+    <ImageView
+        android:id="@+id/ivCall"
+        android:layout_width="50dp"
+        android:layout_height="50dp"
+        android:layout_marginStart="8dp"
+        android:layout_marginLeft="8dp"
+        android:layout_marginBottom="8dp"
+        android:contentDescription="@string/main_call_icon"
+        android:padding="13dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:srcCompat="@drawable/ic_call" />
+
+    <ImageView
+        android:id="@+id/ivCamera"
+        android:layout_width="50dp"
+        android:layout_height="50dp"
+        android:layout_marginEnd="8dp"
+        android:layout_marginRight="8dp"
+        android:layout_marginBottom="8dp"
+        android:contentDescription="@string/main_photo_camera_icon"
+        android:padding="13dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:srcCompat="@drawable/ic_photo_camera" />
+
+</android.support.constraint.ConstraintLayout>

+ 13 - 0
app/src/main/res/layout-sw600dp/main_fragment.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/main"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".ui.main.MainFragment">
+
+    <include layout="@layout/main_content" />
+
+    <include layout="@layout/main_bottom_sheet" />
+
+</android.support.design.widget.CoordinatorLayout>

+ 0 - 16
app/src/main/res/layout-sw720dp/main_activity.xml

@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:id="@+id/main_activity_container"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    tools:context=".MainActivity">
-
-    <fragment xmlns:app="http://schemas.android.com/apk/res-auto"
-        android:id="@+id/nav_host_fragment"
-        android:name="androidx.navigation.fragment.NavHostFragment"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        app:defaultNavHost="true"
-        app:navGraph="@navigation/nav_graph" />
-</merge>

+ 0 - 19
app/src/main/res/layout-sw720dp/main_list_item.xml

@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content">
-
-    <TextView
-        android:id="@+id/main_label"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="24dp"
-        android:layout_marginLeft="24dp"
-        android:layout_marginTop="32dp"
-        android:layout_marginBottom="32dp"
-        android:textSize="72sp"
-        app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent" />
-</android.support.constraint.ConstraintLayout>

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

@@ -5,7 +5,7 @@
     android:id="@+id/bottomSheet"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    app:behavior_peekHeight="50dp"
+    app:behavior_peekHeight="0dp"
     app:behavior_skipCollapsed="true"
     app:cardBackgroundColor="?android:attr/colorBackground"
     app:cardCornerRadius="0dp"

+ 29 - 2
app/src/main/res/layout/main_content.xml

@@ -29,7 +29,7 @@
     <android.support.v7.widget.RecyclerView
         android:id="@+id/mainAppsList"
         android:layout_width="0dp"
-        android:layout_height="wrap_content"
+        android:layout_height="400dp"
         android:layout_marginStart="16dp"
         android:layout_marginLeft="16dp"
         android:layout_marginTop="32dp"
@@ -49,12 +49,39 @@
         android:layout_marginStart="8dp"
         android:layout_marginLeft="8dp"
         android:layout_marginEnd="8dp"
-        android:contentDescription="@string/content_description_expand_up"
         android:layout_marginRight="8dp"
+        android:layout_marginBottom="8dp"
+        android:contentDescription="@string/content_description_expand_up"
         android:padding="8dp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:srcCompat="@drawable/ic_expand" />
 
+    <ImageView
+        android:id="@+id/ivCall"
+        android:layout_width="50dp"
+        android:layout_height="50dp"
+        android:layout_marginStart="8dp"
+        android:layout_marginLeft="8dp"
+        android:layout_marginBottom="8dp"
+        android:padding="13dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:srcCompat="@drawable/ic_call"
+        android:contentDescription="@string/main_call_icon" />
+
+    <ImageView
+        android:id="@+id/ivCamera"
+        android:layout_width="50dp"
+        android:layout_height="50dp"
+        android:layout_marginEnd="8dp"
+        android:layout_marginRight="8dp"
+        android:layout_marginBottom="8dp"
+        android:padding="13dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:srcCompat="@drawable/ic_photo_camera"
+        android:contentDescription="@string/main_photo_camera_icon" />
+
 </android.support.constraint.ConstraintLayout>

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

@@ -5,7 +5,7 @@
     android:id="@+id/frameLayout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    tools:context=".ui.apps.SettingsFragment">
+    tools:context=".ui.main.SettingsFragment">
 
     <!-- TODO: Update blank fragment layout -->
 

+ 2 - 2
app/src/main/res/navigation/nav_graph.xml

@@ -19,7 +19,7 @@
     </fragment>
     <fragment
         android:id="@+id/settingsFragment"
-        android:name="com.sduduzog.slimlauncher.ui.apps.SettingsFragment"
+        android:name="com.sduduzog.slimlauncher.ui.main.SettingsFragment"
         android:label="fragment_settings"
         tools:layout="@layout/settings_fragment">
         <action
@@ -28,7 +28,7 @@
     </fragment>
     <fragment
         android:id="@+id/appsFragment"
-        android:name="com.sduduzog.slimlauncher.ui.apps.AppsFragment"
+        android:name="com.sduduzog.slimlauncher.ui.main.AppsFragment"
         android:label="fragment_apps_list"
         tools:layout="@layout/apps_fragment" />
     <fragment

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -57,5 +57,7 @@
     </string>
     <string name="content_description_expand_up">Expand up icon</string>
     <string name="theme_chooser_dialog_title">Change theme</string>
+    <string name="main_call_icon">call icon</string>
+    <string name="main_photo_camera_icon">photo camera icon</string>
 
 </resources>