mirror of
				https://github.com/SimpleMobileTools/Simple-App-Launcher.git
				synced 2025-06-05 21:49:21 +02:00 
			
		
		
		
	some updates here and there
This commit is contained in:
		| @@ -15,7 +15,10 @@ | |||||||
|         android:label="@string/app_launcher_name" |         android:label="@string/app_launcher_name" | ||||||
|         android:supportsRtl="true" |         android:supportsRtl="true" | ||||||
|         android:theme="@style/AppTheme"> |         android:theme="@style/AppTheme"> | ||||||
|         <activity android:name=".activities.MainActivity"> |  | ||||||
|  |         <activity | ||||||
|  |             android:name=".activities.SplashActivity" | ||||||
|  |             android:theme="@style/SplashTheme"> | ||||||
|             <intent-filter> |             <intent-filter> | ||||||
|                 <action android:name="android.intent.action.MAIN"/> |                 <action android:name="android.intent.action.MAIN"/> | ||||||
|  |  | ||||||
| @@ -23,19 +26,27 @@ | |||||||
|             </intent-filter> |             </intent-filter> | ||||||
|         </activity> |         </activity> | ||||||
|  |  | ||||||
|         <activity |         <activity android:name=".activities.MainActivity"/> | ||||||
|             android:name=".activities.AboutActivity" |  | ||||||
|             android:label="@string/about" |  | ||||||
|             android:parentActivityName=".activities.MainActivity"/> |  | ||||||
|  |  | ||||||
|         <activity |  | ||||||
|             android:name=".activities.LicenseActivity" |  | ||||||
|             android:label="@string/third_party_licences" |  | ||||||
|             android:parentActivityName=".activities.AboutActivity"/> |  | ||||||
|  |  | ||||||
|         <activity |         <activity | ||||||
|             android:name=".activities.SettingsActivity" |             android:name=".activities.SettingsActivity" | ||||||
|             android:label="@string/settings" |             android:label="@string/settings" | ||||||
|             android:parentActivityName=".activities.MainActivity"/> |             android:parentActivityName=".activities.MainActivity"/> | ||||||
|  |  | ||||||
|  |         <activity | ||||||
|  |             android:name="com.simplemobiletools.commons.activities.AboutActivity" | ||||||
|  |             android:label="@string/about" | ||||||
|  |             android:parentActivityName=".activities.MainActivity"/> | ||||||
|  |  | ||||||
|  |         <activity | ||||||
|  |             android:name="com.simplemobiletools.commons.activities.LicenseActivity" | ||||||
|  |             android:label="@string/third_party_licences" | ||||||
|  |             android:parentActivityName="com.simplemobiletools.commons.activities.AboutActivity"/> | ||||||
|  |  | ||||||
|  |         <activity | ||||||
|  |             android:name="com.simplemobiletools.commons.activities.CustomizationActivity" | ||||||
|  |             android:label="@string/customize_colors" | ||||||
|  |             android:parentActivityName=".activities.SettingsActivity"/> | ||||||
|  |  | ||||||
|     </application> |     </application> | ||||||
| </manifest> | </manifest> | ||||||
|   | |||||||
| @@ -1,105 +0,0 @@ | |||||||
| package com.simplemobiletools.applauncher.activities |  | ||||||
|  |  | ||||||
| import android.content.ActivityNotFoundException |  | ||||||
| import android.content.Intent |  | ||||||
| import android.os.Bundle |  | ||||||
| import android.text.Html |  | ||||||
| import android.text.method.LinkMovementMethod |  | ||||||
| import android.view.View |  | ||||||
| import com.simplemobiletools.applauncher.BuildConfig |  | ||||||
| import com.simplemobiletools.applauncher.R |  | ||||||
| import com.simplemobiletools.applauncher.extensions.isFirstRun |  | ||||||
| import com.simplemobiletools.applauncher.extensions.preferences |  | ||||||
| import com.simplemobiletools.applauncher.extensions.viewIntent |  | ||||||
| import kotlinx.android.synthetic.main.activity_about.* |  | ||||||
| import java.util.* |  | ||||||
|  |  | ||||||
| class AboutActivity : SimpleActivity() { |  | ||||||
|  |  | ||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |  | ||||||
|         super.onCreate(savedInstanceState) |  | ||||||
|         setContentView(R.layout.activity_about) |  | ||||||
|  |  | ||||||
|         setupEmail() |  | ||||||
|         setupInvite() |  | ||||||
|         setupRateUs() |  | ||||||
|         setupLicense() |  | ||||||
|         setupSocial() |  | ||||||
|         setupCopyright() |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun setupEmail() { |  | ||||||
|         val email = getString(R.string.email) |  | ||||||
|         val appName = getString(R.string.app_name) |  | ||||||
|         val href = "<a href=\"mailto:$email?subject=$appName\">$email</a>" |  | ||||||
|         about_email.text = Html.fromHtml(href) |  | ||||||
|         about_email.movementMethod = LinkMovementMethod.getInstance() |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun setupInvite() { |  | ||||||
|         val intent = Intent() |  | ||||||
|         val text = String.format(getString(R.string.share_text), getString(R.string.app_name), getStoreUrl()) |  | ||||||
|         intent.action = Intent.ACTION_SEND |  | ||||||
|         intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name)) |  | ||||||
|         intent.putExtra(Intent.EXTRA_TEXT, text) |  | ||||||
|         intent.type = "text/plain" |  | ||||||
|  |  | ||||||
|         about_invite.setOnClickListener { |  | ||||||
|             startActivity(Intent.createChooser(intent, getString(R.string.invite_via))) |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun setupRateUs() { |  | ||||||
|         if (preferences.isFirstRun) { |  | ||||||
|             about_rate_us.visibility = View.GONE |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         about_rate_us.setOnClickListener { |  | ||||||
|             startActivity(viewIntent(getRateUsUrl())) |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun setupLicense() { |  | ||||||
|         about_license.setOnClickListener { |  | ||||||
|             startActivity(Intent(applicationContext, LicenseActivity::class.java)) |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun setupSocial() { |  | ||||||
|         about_facebook.setOnClickListener { |  | ||||||
|             startActivity(viewIntent(getFacebookUrl())) |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         about_gplus.setOnClickListener { |  | ||||||
|             val link = "https://plus.google.com/communities/104880861558693868382" |  | ||||||
|             startActivity(viewIntent(link)) |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun setupCopyright() { |  | ||||||
|         val versionName = BuildConfig.VERSION_NAME |  | ||||||
|         val year = Calendar.getInstance().get(Calendar.YEAR) |  | ||||||
|         about_copyright.text = String.format(getString(R.string.copyright), versionName, year) |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun getFacebookUrl(): String { |  | ||||||
|         try { |  | ||||||
|             packageManager.getPackageInfo("com.facebook.katana", 0) |  | ||||||
|             return "fb://page/150270895341774" |  | ||||||
|         } catch (ignored: Exception) { |  | ||||||
|             return "https://www.facebook.com/simplemobiletools" |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun getRateUsUrl(): String { |  | ||||||
|         try { |  | ||||||
|             return "market://details?id=" + packageName |  | ||||||
|         } catch (ignored: ActivityNotFoundException) { |  | ||||||
|             return getStoreUrl() |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun getStoreUrl(): String { |  | ||||||
|         return "https://play.google.com/store/apps/details?id=" + packageName |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,22 +0,0 @@ | |||||||
| package com.simplemobiletools.applauncher.activities |  | ||||||
|  |  | ||||||
| import android.os.Bundle |  | ||||||
| import com.simplemobiletools.applauncher.R |  | ||||||
| import com.simplemobiletools.applauncher.extensions.viewIntent |  | ||||||
| import kotlinx.android.synthetic.main.activity_license.* |  | ||||||
|  |  | ||||||
| class LicenseActivity : SimpleActivity() { |  | ||||||
|  |  | ||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |  | ||||||
|         super.onCreate(savedInstanceState) |  | ||||||
|         setContentView(R.layout.activity_license) |  | ||||||
|  |  | ||||||
|         license_kotlin_title.setOnClickListener { |  | ||||||
|             startActivity(viewIntent(getString(R.string.kotlin_url))) |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         license_multiselect_title.setOnClickListener { |  | ||||||
|             startActivity(viewIntent(getString(R.string.multiselect_url))) |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -2,21 +2,21 @@ package com.simplemobiletools.applauncher.activities | |||||||
|  |  | ||||||
| import android.content.Intent | import android.content.Intent | ||||||
| import android.content.pm.PackageManager | import android.content.pm.PackageManager | ||||||
|  | import android.net.Uri | ||||||
| import android.os.Bundle | import android.os.Bundle | ||||||
| import android.view.Menu | import android.view.Menu | ||||||
| import android.view.MenuItem | import android.view.MenuItem | ||||||
| import android.view.View | import android.widget.ImageView | ||||||
|  | import com.simplemobiletools.applauncher.BuildConfig | ||||||
| import com.simplemobiletools.applauncher.R | import com.simplemobiletools.applauncher.R | ||||||
| import com.simplemobiletools.applauncher.adapters.RecyclerAdapter | import com.simplemobiletools.applauncher.adapters.RecyclerAdapter | ||||||
| import com.simplemobiletools.applauncher.databases.DbHelper | import com.simplemobiletools.applauncher.databases.DbHelper | ||||||
| import com.simplemobiletools.applauncher.dialogs.AddAppDialog | import com.simplemobiletools.applauncher.dialogs.AddAppDialog | ||||||
| import com.simplemobiletools.applauncher.extensions.isFirstRun |  | ||||||
| import com.simplemobiletools.applauncher.extensions.preferences |  | ||||||
| import com.simplemobiletools.applauncher.extensions.viewIntent |  | ||||||
| import com.simplemobiletools.applauncher.models.AppLauncher | import com.simplemobiletools.applauncher.models.AppLauncher | ||||||
|  | import com.simplemobiletools.commons.extensions.beInvisible | ||||||
|  | import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN | ||||||
| import kotlinx.android.synthetic.main.activity_main.* | import kotlinx.android.synthetic.main.activity_main.* | ||||||
| import java.util.* | import java.util.* | ||||||
| import kotlin.comparisons.compareBy |  | ||||||
|  |  | ||||||
| class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, RecyclerAdapter.RecyclerInterface { | class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, RecyclerAdapter.RecyclerInterface { | ||||||
|     lateinit var dbHelper: DbHelper |     lateinit var dbHelper: DbHelper | ||||||
| @@ -39,18 +39,21 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc | |||||||
|         return true |         return true | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onOptionsItemSelected(item: MenuItem?): Boolean { |     override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||||||
|         when (item?.itemId) { |         when (item.itemId) { | ||||||
|             R.id.settings -> { |             R.id.settings -> launchSettings() | ||||||
|  |             R.id.about -> launchAbout() | ||||||
|  |             else -> return super.onOptionsItemSelected(item) | ||||||
|  |         } | ||||||
|  |         return true | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private fun launchSettings() { | ||||||
|         startActivity(Intent(applicationContext, SettingsActivity::class.java)) |         startActivity(Intent(applicationContext, SettingsActivity::class.java)) | ||||||
|                 return true |  | ||||||
|     } |     } | ||||||
|             R.id.about -> { |  | ||||||
|                 startActivity(Intent(applicationContext, AboutActivity::class.java)) |     private fun launchAbout() { | ||||||
|                 return true |         startAboutActivity(R.string.app_name, LICENSE_KOTLIN, BuildConfig.VERSION_NAME) | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         return super.onOptionsItemSelected(item) |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun setupLaunchers() { |     private fun setupLaunchers() { | ||||||
| @@ -62,7 +65,9 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc | |||||||
|                 startActivity(launchIntent) |                 startActivity(launchIntent) | ||||||
|                 finish() |                 finish() | ||||||
|             } else { |             } else { | ||||||
|                 startActivity(viewIntent("https://play.google.com/store/apps/details?id=" + it.pkgName)) |                 val url = "https://play.google.com/store/apps/details?id=${it.pkgName}" | ||||||
|  |                 val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | ||||||
|  |                 startActivity(intent) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -125,19 +130,14 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc | |||||||
|         refreshLaunchers() |         refreshLaunchers() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fun refreshLaunchers() { |     private fun refreshLaunchers() { | ||||||
|         (launchers_holder.adapter as RecyclerAdapter).finishActionMode() |         (launchers_holder.adapter as RecyclerAdapter).finishActionMode() | ||||||
|         setupLaunchers() |         setupLaunchers() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun refreshLauncherIcons() { |     override fun refreshLauncherIcons() { | ||||||
|         for (pos in 0..launchers_holder.childCount - 1) { |         for (pos in 0 until launchers_holder.childCount) { | ||||||
|             launchers_holder.getChildAt(pos).findViewById(R.id.launcher_check).visibility = View.INVISIBLE |             launchers_holder.getChildAt(pos).findViewById<ImageView>(R.id.launcher_check).beInvisible() | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onDestroy() { |  | ||||||
|         super.onDestroy() |  | ||||||
|         preferences.isFirstRun = false |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,31 +1,12 @@ | |||||||
| package com.simplemobiletools.applauncher.activities | package com.simplemobiletools.applauncher.activities | ||||||
|  |  | ||||||
| import android.os.Bundle | import android.os.Bundle | ||||||
| import android.support.v4.app.TaskStackBuilder |  | ||||||
| import com.simplemobiletools.applauncher.R | import com.simplemobiletools.applauncher.R | ||||||
| import com.simplemobiletools.applauncher.extensions.isDarkTheme |  | ||||||
| import com.simplemobiletools.applauncher.extensions.preferences |  | ||||||
| import kotlinx.android.synthetic.main.activity_settings.* |  | ||||||
|  |  | ||||||
| class SettingsActivity : SimpleActivity() { | class SettingsActivity : SimpleActivity() { | ||||||
|  |  | ||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |     override fun onCreate(savedInstanceState: Bundle?) { | ||||||
|         super.onCreate(savedInstanceState) |         super.onCreate(savedInstanceState) | ||||||
|         setContentView(R.layout.activity_settings) |         setContentView(R.layout.activity_settings) | ||||||
|         setupDarkTheme() |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun setupDarkTheme() { |  | ||||||
|         settings_dark_theme.isChecked = preferences.isDarkTheme |  | ||||||
|  |  | ||||||
|         settings_dark_theme_holder.setOnClickListener { |  | ||||||
|             settings_dark_theme.toggle() |  | ||||||
|             preferences.isDarkTheme = settings_dark_theme.isChecked |  | ||||||
|             restartActivity() |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun restartActivity() { |  | ||||||
|         TaskStackBuilder.create(applicationContext).addNextIntentWithParentStack(intent).startActivities() |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,25 +1,5 @@ | |||||||
| package com.simplemobiletools.applauncher.activities | package com.simplemobiletools.applauncher.activities | ||||||
|  |  | ||||||
| import android.os.Bundle | import com.simplemobiletools.commons.activities.BaseSimpleActivity | ||||||
| import android.support.v7.app.AppCompatActivity |  | ||||||
| import android.view.MenuItem |  | ||||||
| import com.simplemobiletools.applauncher.R |  | ||||||
| import com.simplemobiletools.applauncher.extensions.isDarkTheme |  | ||||||
| import com.simplemobiletools.applauncher.extensions.preferences |  | ||||||
|  |  | ||||||
| open class SimpleActivity : AppCompatActivity() { | open class SimpleActivity : BaseSimpleActivity() | ||||||
|     override fun onCreate(savedInstanceState: Bundle?) { |  | ||||||
|         setTheme(if (preferences.isDarkTheme) R.style.AppTheme_Dark else R.style.AppTheme) |  | ||||||
|         super.onCreate(savedInstanceState) |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     override fun onOptionsItemSelected(item: MenuItem?): Boolean { |  | ||||||
|         when (item?.itemId) { |  | ||||||
|             android.R.id.home -> { |  | ||||||
|                 finish() |  | ||||||
|                 return true |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         return super.onOptionsItemSelected(item) |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|   | |||||||
| @@ -0,0 +1,13 @@ | |||||||
|  | package com.simplemobiletools.applauncher.activities | ||||||
|  |  | ||||||
|  | import android.content.Intent | ||||||
|  | import android.os.Bundle | ||||||
|  | import android.support.v7.app.AppCompatActivity | ||||||
|  |  | ||||||
|  | class SplashActivity : AppCompatActivity() { | ||||||
|  |     override fun onCreate(savedInstanceState: Bundle?) { | ||||||
|  |         super.onCreate(savedInstanceState) | ||||||
|  |         startActivity(Intent(this, MainActivity::class.java)) | ||||||
|  |         finish() | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -12,10 +12,10 @@ import com.bignerdranch.android.multiselector.MultiSelector | |||||||
| import com.bignerdranch.android.multiselector.SwappingHolder | import com.bignerdranch.android.multiselector.SwappingHolder | ||||||
| import com.simplemobiletools.applauncher.R | import com.simplemobiletools.applauncher.R | ||||||
| import com.simplemobiletools.applauncher.databases.DbHelper | import com.simplemobiletools.applauncher.databases.DbHelper | ||||||
| import com.simplemobiletools.applauncher.extensions.hide |  | ||||||
| import com.simplemobiletools.applauncher.extensions.show |  | ||||||
| import com.simplemobiletools.applauncher.extensions.toast |  | ||||||
| import com.simplemobiletools.applauncher.models.AppLauncher | import com.simplemobiletools.applauncher.models.AppLauncher | ||||||
|  | import com.simplemobiletools.commons.extensions.beInvisibleIf | ||||||
|  | import com.simplemobiletools.commons.extensions.beVisible | ||||||
|  | import com.simplemobiletools.commons.extensions.toast | ||||||
| import kotlinx.android.synthetic.main.app_launcher_item.view.* | import kotlinx.android.synthetic.main.app_launcher_item.view.* | ||||||
| import kotlinx.android.synthetic.main.edit_launcher.view.* | import kotlinx.android.synthetic.main.edit_launcher.view.* | ||||||
| import java.util.* | import java.util.* | ||||||
| @@ -152,7 +152,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i | |||||||
|                         (act as AppCompatActivity).startSupportActionMode(multiSelectorCallback) |                         (act as AppCompatActivity).startSupportActionMode(multiSelectorCallback) | ||||||
|                         multiSelector.setSelected(viewHolder, true) |                         multiSelector.setSelected(viewHolder, true) | ||||||
|                         actMode?.title = multiSelector.selectedPositions.size.toString() |                         actMode?.title = multiSelector.selectedPositions.size.toString() | ||||||
|                         itemView.launcher_check.show() |                         itemView.launcher_check.beVisible() | ||||||
|                     } |                     } | ||||||
|                     true |                     true | ||||||
|                 } |                 } | ||||||
| @@ -171,11 +171,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i | |||||||
|             if (multiSelector.isSelectable) { |             if (multiSelector.isSelectable) { | ||||||
|                 val isSelected = multiSelector.selectedPositions.contains(viewHolder.layoutPosition) |                 val isSelected = multiSelector.selectedPositions.contains(viewHolder.layoutPosition) | ||||||
|                 multiSelector.setSelected(viewHolder, !isSelected) |                 multiSelector.setSelected(viewHolder, !isSelected) | ||||||
|                 if (isSelected) { |                 itemView.launcher_check.beInvisibleIf(isSelected) | ||||||
|                     itemView.launcher_check.hide() |  | ||||||
|                 } else { |  | ||||||
|                     itemView.launcher_check.show() |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 val selectedCnt = multiSelector.selectedPositions.size |                 val selectedCnt = multiSelector.selectedPositions.size | ||||||
|                 if (selectedCnt == 0) { |                 if (selectedCnt == 0) { | ||||||
|   | |||||||
| @@ -6,9 +6,8 @@ import android.view.LayoutInflater | |||||||
| import android.view.View | import android.view.View | ||||||
| import android.view.ViewGroup | import android.view.ViewGroup | ||||||
| import com.simplemobiletools.applauncher.R | import com.simplemobiletools.applauncher.R | ||||||
| import com.simplemobiletools.applauncher.extensions.hide |  | ||||||
| import com.simplemobiletools.applauncher.extensions.show |  | ||||||
| import com.simplemobiletools.applauncher.models.AppLauncher | import com.simplemobiletools.applauncher.models.AppLauncher | ||||||
|  | import com.simplemobiletools.commons.extensions.beInvisibleIf | ||||||
| import kotlinx.android.synthetic.main.app_launcher_item.view.* | import kotlinx.android.synthetic.main.app_launcher_item.view.* | ||||||
|  |  | ||||||
| class RecyclerDialogAdapter(val cxt: Context, val launchers: List<AppLauncher>) : RecyclerView.Adapter<RecyclerDialogAdapter.ViewHolder>() { | class RecyclerDialogAdapter(val cxt: Context, val launchers: List<AppLauncher>) : RecyclerView.Adapter<RecyclerDialogAdapter.ViewHolder>() { | ||||||
| @@ -22,9 +21,7 @@ class RecyclerDialogAdapter(val cxt: Context, val launchers: List<AppLauncher>) | |||||||
|         return ViewHolder(view) |         return ViewHolder(view) | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun getItemCount(): Int { |     override fun getItemCount() = launchers.count() | ||||||
|         return launchers.count() |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { |     class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { | ||||||
|         fun bindView(context: Context, launcher: AppLauncher) { |         fun bindView(context: Context, launcher: AppLauncher) { | ||||||
| @@ -47,11 +44,7 @@ class RecyclerDialogAdapter(val cxt: Context, val launchers: List<AppLauncher>) | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         fun handleCheck(check: View, launcher: AppLauncher) { |         fun handleCheck(check: View, launcher: AppLauncher) { | ||||||
|             if (launcher.isChecked) { |             check.beInvisibleIf(!launcher.isChecked) | ||||||
|                 check.show() |  | ||||||
|             } else { |  | ||||||
|                 check.hide() |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -28,7 +28,16 @@ class DbHelper(context: Context) : SQLiteOpenHelper(context, "launchers.db", nul | |||||||
|         val POSITION: String = "position" |         val POSITION: String = "position" | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fun addInitialLaunchers(db: SQLiteDatabase) { |  | ||||||
|  |     override fun onCreate(db: SQLiteDatabase) { | ||||||
|  |         db.execSQL(CREATE_DB) | ||||||
|  |         addInitialLaunchers(db) | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) { | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private fun addInitialLaunchers(db: SQLiteDatabase) { | ||||||
|         addLauncher(string(R.string.calculator), "com.simplemobiletools.calculator", R.mipmap.calculator, db) |         addLauncher(string(R.string.calculator), "com.simplemobiletools.calculator", R.mipmap.calculator, db) | ||||||
|         addLauncher(string(R.string.calendar), "com.simplemobiletools.calendar", R.mipmap.calendar, db) |         addLauncher(string(R.string.calendar), "com.simplemobiletools.calendar", R.mipmap.calendar, db) | ||||||
|         addLauncher(string(R.string.camera), "com.simplemobiletools.camera", R.mipmap.camera, db) |         addLauncher(string(R.string.camera), "com.simplemobiletools.camera", R.mipmap.camera, db) | ||||||
| @@ -64,7 +73,7 @@ class DbHelper(context: Context) : SQLiteOpenHelper(context, "launchers.db", nul | |||||||
|     fun getLaunchers(): ArrayList<AppLauncher> { |     fun getLaunchers(): ArrayList<AppLauncher> { | ||||||
|         val launchers = ArrayList<AppLauncher>() |         val launchers = ArrayList<AppLauncher>() | ||||||
|         val cursor = readableDatabase.query(TABLE, arrayOf(ID, NAME, PKG_NAME, ICON_ID), null, null, null, null, NAME) |         val cursor = readableDatabase.query(TABLE, arrayOf(ID, NAME, PKG_NAME, ICON_ID), null, null, null, null, NAME) | ||||||
|         try { |         cursor.use { | ||||||
|             while (cursor.moveToNext()) { |             while (cursor.moveToNext()) { | ||||||
|                 val id = cursor.getInt(cursor.getColumnIndex(DbHelper.ID)) |                 val id = cursor.getInt(cursor.getColumnIndex(DbHelper.ID)) | ||||||
|                 val name = cursor.getString(cursor.getColumnIndex(DbHelper.NAME)) |                 val name = cursor.getString(cursor.getColumnIndex(DbHelper.NAME)) | ||||||
| @@ -72,22 +81,9 @@ class DbHelper(context: Context) : SQLiteOpenHelper(context, "launchers.db", nul | |||||||
|                 val icon = cursor.getInt(cursor.getColumnIndex(DbHelper.ICON_ID)) |                 val icon = cursor.getInt(cursor.getColumnIndex(DbHelper.ICON_ID)) | ||||||
|                 launchers.add(AppLauncher(id, name, pkgName, icon)) |                 launchers.add(AppLauncher(id, name, pkgName, icon)) | ||||||
|             } |             } | ||||||
|         } finally { |  | ||||||
|             cursor.close() |  | ||||||
|         } |         } | ||||||
|         return launchers |         return launchers | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun onCreate(db: SQLiteDatabase) { |     private fun string(id: Int) = resources.getString(id) | ||||||
|         db.execSQL(CREATE_DB) |  | ||||||
|         addInitialLaunchers(db) |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) { |  | ||||||
|  |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private fun string(id: Int): String { |  | ||||||
|         return resources.getString(id) |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -0,0 +1,6 @@ | |||||||
|  | package com.simplemobiletools.applauncher.extensions | ||||||
|  |  | ||||||
|  | import android.content.Context | ||||||
|  | import com.simplemobiletools.applauncher.helpers.Config | ||||||
|  |  | ||||||
|  | val Context.config: Config get() = Config.newInstance(applicationContext) | ||||||
| @@ -1,10 +0,0 @@ | |||||||
| package com.simplemobiletools.applauncher.extensions |  | ||||||
|  |  | ||||||
| import android.content.Context |  | ||||||
| import android.content.Intent |  | ||||||
| import android.net.Uri |  | ||||||
| import android.widget.Toast |  | ||||||
|  |  | ||||||
| fun Context.viewIntent(url: String): Intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) |  | ||||||
|  |  | ||||||
| fun Context.toast(msgId: Int, duration: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, resources.getString(msgId), duration).show() |  | ||||||
| @@ -1,33 +0,0 @@ | |||||||
| package com.simplemobiletools.applauncher.extensions |  | ||||||
|  |  | ||||||
| import android.content.Context |  | ||||||
| import android.content.SharedPreferences |  | ||||||
|  |  | ||||||
| val PREFS_KEY = "App Launcher" |  | ||||||
| val IS_FIRST_RUN = "is_first_run" |  | ||||||
| val IS_DARK_THEME = "is_dark_theme" |  | ||||||
|  |  | ||||||
| private val defaultInit: Any.() -> Unit = {} |  | ||||||
|  |  | ||||||
| val Context.preferences: SharedPreferences get() = preferences() |  | ||||||
| fun Context.preferences(init: SharedPreferences.() -> Unit = defaultInit): SharedPreferences { |  | ||||||
|     val defaultPreferences = getSharedPreferences(PREFS_KEY, Context.MODE_PRIVATE) |  | ||||||
|     defaultPreferences.init() |  | ||||||
|     return defaultPreferences |  | ||||||
| } |  | ||||||
|  |  | ||||||
| var SharedPreferences.isFirstRun: Boolean |  | ||||||
|     set(isFirstRun: Boolean) { |  | ||||||
|         edit().putBoolean(IS_FIRST_RUN, isFirstRun).apply() |  | ||||||
|     } |  | ||||||
|     get() { |  | ||||||
|         return getBoolean(IS_FIRST_RUN, true) |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| var SharedPreferences.isDarkTheme: Boolean |  | ||||||
|     set(isDarkTheme: Boolean) { |  | ||||||
|         edit().putBoolean(IS_DARK_THEME, isDarkTheme).apply() |  | ||||||
|     } |  | ||||||
|     get() { |  | ||||||
|         return getBoolean(IS_DARK_THEME, false) |  | ||||||
|     } |  | ||||||
| @@ -1,11 +0,0 @@ | |||||||
| package com.simplemobiletools.applauncher.extensions |  | ||||||
|  |  | ||||||
| import android.view.View |  | ||||||
|  |  | ||||||
| fun View.hide() { |  | ||||||
|     visibility = View.INVISIBLE |  | ||||||
| } |  | ||||||
|  |  | ||||||
| fun View.show() { |  | ||||||
|     visibility = View.VISIBLE |  | ||||||
| } |  | ||||||
| @@ -0,0 +1,10 @@ | |||||||
|  | package com.simplemobiletools.applauncher.helpers | ||||||
|  |  | ||||||
|  | import android.content.Context | ||||||
|  | import com.simplemobiletools.commons.helpers.BaseConfig | ||||||
|  |  | ||||||
|  | class Config(context: Context) : BaseConfig(context) { | ||||||
|  |     companion object { | ||||||
|  |         fun newInstance(context: Context) = Config(context) | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -2,6 +2,6 @@ package com.simplemobiletools.applauncher.models | |||||||
|  |  | ||||||
| data class AppLauncher(val id: Int, var name: String, val pkgName: String, val iconId: Int, var isChecked: Boolean = false) { | data class AppLauncher(val id: Int, var name: String, val pkgName: String, val iconId: Int, var isChecked: Boolean = false) { | ||||||
|     override fun equals(other: Any?): Boolean { |     override fun equals(other: Any?): Boolean { | ||||||
|         return pkgName.equals((other as AppLauncher).pkgName) |         return pkgName.equals((other as AppLauncher).pkgName, true) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,105 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> |  | ||||||
| <ScrollView |  | ||||||
|     android:id="@+id/about_scrollview" |  | ||||||
|     xmlns:android="http://schemas.android.com/apk/res/android" |  | ||||||
|     android:layout_width="match_parent" |  | ||||||
|     android:layout_height="match_parent" |  | ||||||
|     android:fillViewport="true"> |  | ||||||
|  |  | ||||||
|     <RelativeLayout |  | ||||||
|         android:id="@+id/about_holder" |  | ||||||
|         android:layout_width="match_parent" |  | ||||||
|         android:layout_height="wrap_content" |  | ||||||
|         android:paddingBottom="@dimen/activity_margin" |  | ||||||
|         android:paddingLeft="@dimen/activity_margin" |  | ||||||
|         android:paddingTop="@dimen/activity_margin"> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/about_website" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:autoLink="web" |  | ||||||
|             android:text="@string/website"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/about_email_label" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:layout_below="@+id/about_website" |  | ||||||
|             android:layout_marginTop="@dimen/activity_margin" |  | ||||||
|             android:text="@string/email_label"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/about_email" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:layout_below="@+id/about_email_label" |  | ||||||
|             android:paddingBottom="@dimen/activity_margin" |  | ||||||
|             android:text="@string/email"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/about_invite" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:layout_below="@+id/about_email" |  | ||||||
|             android:paddingBottom="@dimen/activity_margin" |  | ||||||
|             android:paddingTop="@dimen/activity_margin" |  | ||||||
|             android:text="@string/invite_friends_underlined" |  | ||||||
|             android:textColor="@color/colorPrimary"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/about_rate_us" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:layout_below="@+id/about_invite" |  | ||||||
|             android:paddingBottom="@dimen/activity_margin" |  | ||||||
|             android:paddingTop="@dimen/activity_margin" |  | ||||||
|             android:text="@string/rate_us_underlined" |  | ||||||
|             android:textColor="@color/colorPrimary"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/about_license" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:layout_below="@+id/about_rate_us" |  | ||||||
|             android:paddingBottom="@dimen/activity_margin" |  | ||||||
|             android:paddingTop="@dimen/activity_margin" |  | ||||||
|             android:text="@string/third_party_licences_underlined" |  | ||||||
|             android:textColor="@color/colorPrimary"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/about_follow_us" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:layout_below="@+id/about_license" |  | ||||||
|             android:paddingBottom="@dimen/social_padding" |  | ||||||
|             android:paddingTop="@dimen/activity_margin" |  | ||||||
|             android:text="@string/follow_us"/> |  | ||||||
|  |  | ||||||
|         <ImageView |  | ||||||
|             android:id="@+id/about_facebook" |  | ||||||
|             android:layout_width="@dimen/social_logo" |  | ||||||
|             android:layout_height="@dimen/social_logo" |  | ||||||
|             android:layout_below="@+id/about_follow_us" |  | ||||||
|             android:src="@mipmap/facebook"/> |  | ||||||
|  |  | ||||||
|         <ImageView |  | ||||||
|             android:id="@+id/about_gplus" |  | ||||||
|             android:layout_width="@dimen/social_logo" |  | ||||||
|             android:layout_height="@dimen/social_logo" |  | ||||||
|             android:layout_below="@+id/about_follow_us" |  | ||||||
|             android:layout_marginLeft="@dimen/social_padding" |  | ||||||
|             android:layout_toRightOf="@+id/about_facebook" |  | ||||||
|             android:src="@mipmap/gplus"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/about_copyright" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="match_parent" |  | ||||||
|             android:layout_alignParentBottom="true" |  | ||||||
|             android:layout_below="@+id/about_gplus" |  | ||||||
|             android:gravity="center_horizontal|bottom" |  | ||||||
|             android:paddingTop="@dimen/activity_margin" |  | ||||||
|             android:text="v1.0\nCopyright © Simple Mobile Tools 2016"/> |  | ||||||
|     </RelativeLayout> |  | ||||||
| </ScrollView> |  | ||||||
| @@ -1,50 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> |  | ||||||
| <ScrollView |  | ||||||
|     android:id="@+id/license_holder" |  | ||||||
|     xmlns:android="http://schemas.android.com/apk/res/android" |  | ||||||
|     android:layout_width="match_parent" |  | ||||||
|     android:layout_height="match_parent"> |  | ||||||
|  |  | ||||||
|     <LinearLayout |  | ||||||
|         android:id="@+id/license" |  | ||||||
|         android:layout_width="match_parent" |  | ||||||
|         android:layout_height="wrap_content" |  | ||||||
|         android:orientation="vertical" |  | ||||||
|         android:padding="@dimen/activity_margin"> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/license_notice" |  | ||||||
|             android:layout_width="wrap_content" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:text="@string/notice"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/license_kotlin_title" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:paddingTop="@dimen/activity_margin" |  | ||||||
|             android:text="@string/kotlin_title" |  | ||||||
|             android:textColor="@color/colorPrimary"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/license_kotlin_text" |  | ||||||
|             android:layout_width="wrap_content" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:text="@string/kotlin_text"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/license_multiselect_title" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:paddingTop="@dimen/activity_margin" |  | ||||||
|             android:text="@string/multiselect_title" |  | ||||||
|             android:textColor="@color/colorPrimary"/> |  | ||||||
|  |  | ||||||
|         <TextView |  | ||||||
|             android:id="@+id/license_multiselect_text" |  | ||||||
|             android:layout_width="wrap_content" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:text="@string/multiselect_text"/> |  | ||||||
|  |  | ||||||
|     </LinearLayout> |  | ||||||
| </ScrollView> |  | ||||||
| @@ -1,7 +1,7 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||||
| <ScrollView | <ScrollView | ||||||
|     android:id="@+id/settings_scrollview" |  | ||||||
|     xmlns:android="http://schemas.android.com/apk/res/android" |     xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |     android:id="@+id/settings_scrollview" | ||||||
|     android:layout_width="match_parent" |     android:layout_width="match_parent" | ||||||
|     android:layout_height="wrap_content"> |     android:layout_height="wrap_content"> | ||||||
|  |  | ||||||
| @@ -11,30 +11,5 @@ | |||||||
|         android:layout_height="wrap_content" |         android:layout_height="wrap_content" | ||||||
|         android:orientation="vertical"> |         android:orientation="vertical"> | ||||||
|  |  | ||||||
|         <RelativeLayout |  | ||||||
|             android:id="@+id/settings_dark_theme_holder" |  | ||||||
|             android:layout_width="match_parent" |  | ||||||
|             android:layout_height="wrap_content" |  | ||||||
|             android:layout_marginTop="@dimen/settings_padding" |  | ||||||
|             android:background="?attr/selectableItemBackground" |  | ||||||
|             android:padding="@dimen/activity_margin"> |  | ||||||
|  |  | ||||||
|             <TextView |  | ||||||
|                 android:id="@+id/settings_dark_theme_label" |  | ||||||
|                 android:layout_width="wrap_content" |  | ||||||
|                 android:layout_height="wrap_content" |  | ||||||
|                 android:layout_centerVertical="true" |  | ||||||
|                 android:paddingLeft="@dimen/settings_padding" |  | ||||||
|                 android:text="@string/dark_theme"/> |  | ||||||
|  |  | ||||||
|             <android.support.v7.widget.SwitchCompat |  | ||||||
|                 android:id="@+id/settings_dark_theme" |  | ||||||
|                 android:layout_width="wrap_content" |  | ||||||
|                 android:layout_height="wrap_content" |  | ||||||
|                 android:layout_alignParentRight="true" |  | ||||||
|                 android:background="@null" |  | ||||||
|                 android:clickable="false"/> |  | ||||||
|  |  | ||||||
|         </RelativeLayout> |  | ||||||
|     </LinearLayout> |     </LinearLayout> | ||||||
| </ScrollView> | </ScrollView> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user