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

Merge pull request #4 from subbramanil/feature/improve_code_quality

Improves Code Quality
Beautus Sduduzo Gumede преди 7 години
родител
ревизия
f4c1c254aa

+ 6 - 3
README.md

@@ -11,15 +11,18 @@ The project got inspired by LessPhone [LessPhone](https://play.google.com/store/
 I liked it so much but I couldn't do with just 3 apps as daily apps so tah-daaa Slim launcher, everyone!
 
 ## TODO
+
 ### Features that I think will make this really cool for the app
+
 - quick voice recorder
 - notes app
 - todo list
 
 ### For the project
--Migrate to stable version of android studio for better contribution accessibility
--Write all tests for the app
 
-# Contribute
+- Migrate to stable version of android studio for better contribution accessibility
+- Write all tests for the app
+
+### Contribute
 
 - PRs are more than welcome.

+ 2 - 4
app/build.gradle

@@ -60,11 +60,9 @@ dependencies {
     testImplementation 'junit:junit:4.12'
     testImplementation 'org.mockito:mockito-core:2.7.6'
     androidTestImplementation 'androidx.room:room-testing:2.1.0-alpha01'
-    androidTestImplementation 'androidx.test:runner:1.1.0-beta02'
-    androidTestImplementation 'androidx.test:rules:1.1.0-beta02'
+    androidTestImplementation 'androidx.test:runner:1.1.0'
+    androidTestImplementation 'androidx.test:rules:1.1.0'
     androidTestImplementation 'androidx.annotation:annotation:1.0.0'
-    androidTestImplementation 'androidx.test:runner:1.1.0-beta02'
-    androidTestImplementation 'androidx.test:rules:1.1.0-beta02'
     androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
     androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
 }

+ 6 - 10
app/src/main/java/com/sduduzog/slimlauncher/ui/main/MainFragment.kt

@@ -51,7 +51,7 @@ class MainFragment : Fragment() {
         super.onActivityCreated(savedInstanceState)
         sheetBehavior = BottomSheetBehavior.from(bottomSheet)
         optionsView.alpha = 0.0f
-        viewModel = ViewModelProviders.of(activity!!).get(MainViewModel::class.java)
+        viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java)
         adapter = MainAppsAdapter(mutableSetOf(), InteractionHandler())
         mainAppsList.adapter = adapter
         viewModel.homeApps.observe(this, Observer {
@@ -149,7 +149,7 @@ class MainFragment : Fragment() {
     }
 
     private fun rateApp() {
-        val uri = Uri.parse("market://details?id=" + context!!.packageName)
+        val uri = Uri.parse("market://details?id=" + context?.packageName)
         val goToMarket = Intent(Intent.ACTION_VIEW, uri)
         goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY or
                 Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
@@ -161,7 +161,7 @@ class MainFragment : Fragment() {
             Log.d(TAG, goToMarket.data?.query)
         } catch (e: ActivityNotFoundException) {
             startActivity(Intent(Intent.ACTION_VIEW,
-                    Uri.parse("http://play.google.com/store/apps/details?id=" + context!!.packageName)))
+                    Uri.parse("http://play.google.com/store/apps/details?id=" + context?.packageName)))
         }
     }
 
@@ -172,13 +172,9 @@ class MainFragment : Fragment() {
     private fun setEventListeners() {
         clockTextView.setOnClickListener {
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-                try {
-                    val intent = Intent(android.provider.AlarmClock.ACTION_SHOW_ALARMS)
-                    intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
-                    startActivity(intent)
-                } catch (e: Exception) {
-                    Log.e(TAG, e.message)
-                }
+                val intent = Intent(android.provider.AlarmClock.ACTION_SHOW_ALARMS)
+                intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
+                startActivity(intent)
             }
         }
         bottomSheet.setOnClickListener {

+ 1 - 1
app/src/main/java/com/sduduzog/slimlauncher/ui/main/setup/SetupFragment.kt

@@ -39,7 +39,7 @@ class SetupFragment : Fragment(), DialogInteractionListener {
 
     override fun onActivityCreated(savedInstanceState: Bundle?) {
         super.onActivityCreated(savedInstanceState)
-        viewModel = ViewModelProviders.of(activity!!).get(MainViewModel::class.java)
+        viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java)
         setLoading()
         viewModel.homeApps.observe(this, ValueObserver())
         setupButton.setOnClickListener {