Skip to content

Commit

Permalink
Merge pull request #16 from tasomaniac/configure-redesign
Browse files Browse the repository at this point in the history
Configure redesign
  • Loading branch information
tasomaniac authored Jan 23, 2019
2 parents 809193d + e62a184 commit 77ce3b4
Show file tree
Hide file tree
Showing 96 changed files with 864 additions and 659 deletions.
3 changes: 2 additions & 1 deletion .idea/dictionaries/tasomaniac.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 2 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ apply plugin: 'com.android.application'
apply from: configFile('android-common-config.gradle')
apply plugin: 'com.novoda.android-command'
apply plugin: 'com.novoda.build-properties'
if (isPlay) {
apply plugin: 'io.fabric'
apply plugin: 'com.github.triplet.play'
}

buildProperties {
signing.using(configFile('release.signing')) | configFile('debug.signing')
secrets.using(configFile('secrets.properties'))
}

def secrets = buildProperties.secrets

android {
defaultConfig {
applicationId 'com.tasomaniac.devwidget'
Expand All @@ -38,7 +32,6 @@ android {

buildTypes {
debug {
ext.enableCrashlytics = false
applicationIdSuffix '.debug'
versionNameSuffix '-debug'
signingConfig signingConfigs.debug
Expand All @@ -63,11 +56,8 @@ android {
}

if (isPlay) {
play {
serviceAccountEmail = secrets['play_service_account'].or('').string
pk12File = file(secrets['play_key_file'].or('no_file.p12').string)
track = playPublishTrack
}
apply from: configFile('fabric.gradle')
apply from: configFile('play-publish.gradle')
}

dependencies {
Expand All @@ -77,7 +67,6 @@ dependencies {
implementation project(':data')
implementation project(':widget')

playImplementation 'com.crashlytics.sdk.android:crashlytics:2.9.7'
playImplementation 'com.google.firebase:firebase-core:16.0.6'

androidTestImplementation 'androidx.test:runner:1.1.1'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package="com.tasomaniac.devwidget.app">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission-sdk-23 android:name="android.permission.REQUEST_DELETE_PACKAGES" />

<application
android:name=".DevWidgetApp"
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/java/com/tasomaniac/devwidget/app/AppModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
import android.os.UserManager;
import android.preference.PreferenceManager;

import com.tasomaniac.devwidget.extensions.Debouncer;
import com.tasomaniac.devwidget.extensions.DefaultDebouncer;
import com.tasomaniac.devwidget.extensions.SchedulingStrategy;
import com.tasomaniac.devwidget.settings.Version;

import java.util.concurrent.TimeUnit;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;
Expand Down Expand Up @@ -69,9 +65,4 @@ static SchedulingStrategy schedulingStrategy() {
AndroidSchedulers.mainThread()
);
}

@Provides
static Debouncer<String> stringDebouncer() {
return new DefaultDebouncer<>(1, TimeUnit.SECONDS);
}
}
File renamed without changes.
File renamed without changes.
Empty file removed app/src/play/play/contactPhone
Empty file.
File renamed without changes.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v1.5

New Configure screen!

- When adding/editing your widget, now you will see a preview.
- Also, new favorite action. Now, the action on each app can be configured. Was "Uninstall" by default.

v1.4

Android Oreo+ support.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tasomaniac.devwidget

import androidx.fragment.app.FragmentActivity
import com.uber.autodispose.ScopeProvider
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider
import dagger.Module
import dagger.Provides
Expand All @@ -10,5 +11,6 @@ object LifecycleScopeModule {

@Provides
@JvmStatic
internal fun lifecycleScopeProvider(activity: FragmentActivity) = AndroidLifecycleScopeProvider.from(activity)
internal fun lifecycleScopeProvider(activity: FragmentActivity): ScopeProvider =
AndroidLifecycleScopeProvider.from(activity)
}
15 changes: 0 additions & 15 deletions base/src/main/kotlin/com/tasomaniac/devwidget/ViewModelProvider.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.tasomaniac.devwidget

import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.ViewModelProviders
import dagger.Module
import dagger.Provides

@Module
object ViewModelProviderModule {

@Provides
@JvmStatic
fun viewModelProvider(
activity: FragmentActivity,
factory: ViewModelFactory
) = ViewModelProviders.of(activity, factory)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.tasomaniac.devwidget.navigation

fun widgetConfigureCommand(appWidgetId: Int) =
UriCommand("devwidget://configure?appWidgetId=$appWidgetId")

fun settingsCommand() = UriCommand("devwidget://settings")
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.tasomaniac.devwidget.navigation

import android.content.Context
import android.content.Intent
import android.net.Uri

data class UriCommand(val uri: String) : IntentCommand {
override fun createIntent(context: Context): Intent =
Intent(Intent.ACTION_VIEW, Uri.parse(uri))
.setPackage(context.packageName)
}
2 changes: 2 additions & 0 deletions base/src/main/res/values/base_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<string name="delete">Delete</string>
<string name="done">Done</string>
<string name="stop">Stop</string>
<string name="settings">Settings</string>
<string name="general">General</string>

<string name="widget_error_activity_cannot_be_launched">Activity cannot be launched. Make sure it is exported.</string>

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ buildscript {
}

def versionMajor = 1
def versionMinor = 4
def versionBuild = 5
ext.playPublishTrack = 'alpha'
def versionMinor = 5
def versionBuild = 3
ext.playPublishTrack = 'internal'

ext.versions = [
compileSdk : 28,
Expand Down Expand Up @@ -42,7 +42,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:3.5.0-alpha01'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0'
classpath 'com.github.triplet.gradle:play-publisher:1.2.2'
classpath 'com.github.triplet.gradle:play-publisher:2.0.0'
classpath 'com.novoda:gradle-android-command-plugin:2.0.1'
classpath 'com.novoda:gradle-build-properties-plugin:0.4.1'
classpath 'io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0-RC12'
Expand Down
3 changes: 3 additions & 0 deletions configure/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ android {
}

dependencies {
implementation project(':widget')
implementation project(':widget-preview')
implementation project(':data')
implementation 'androidx.preference:preference-ktx:1.0.0'
implementation 'com.jakewharton.rx2:replaying-share-kotlin:2.1.0'

testImplementation project(':test-support')
Expand Down
13 changes: 12 additions & 1 deletion configure/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@
<activity
android:name=".ConfigureActivity"
android:label="@string/widget_configure"
android:windowSoftInputMode="stateAlwaysHidden">
android:theme="@style/Theme.DevWidget.Configure"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />

<data
android:host="configure"
android:scheme="devwidget" />
</intent-filter>
</activity>

<receiver android:name=".WidgetPinnedReceiver" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,65 @@ import android.app.Activity
import android.appwidget.AppWidgetManager
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build.VERSION_CODES.O
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.widget.ArrayAdapter
import androidx.annotation.RequiresApi
import com.tasomaniac.devwidget.data.Analytics
import com.tasomaniac.devwidget.widget.preview.WidgetListData
import dagger.android.support.DaggerAppCompatActivity
import kotlinx.android.synthetic.main.configure_activity.configureWidgetPreview
import kotlinx.android.synthetic.main.configure_activity.toolbar
import kotlinx.android.synthetic.main.configure_content.configureNewPackageMatcher
import kotlinx.android.synthetic.main.configure_content.configurePackageMatcherList
import kotlinx.android.synthetic.main.configure_content.configureWidgetName
import javax.inject.Inject

internal class ConfigureActivity : DaggerAppCompatActivity(), ConfigureView {

@Inject lateinit var presenter: ConfigurePresenter
@Inject lateinit var widgetPreview: WidgetPreview
@Inject lateinit var packageMatcherListAdapter: PackageMatcherListAdapter
@Inject lateinit var analytics: Analytics

private lateinit var adapter: ArrayAdapter<String>
private lateinit var textWatcher: TextWatcher

val configurePin: ConfigurePinning
get() = intent.getBooleanExtra(EXTRA_SHOULD_PIN, false)

override var onConfirmClicked: () -> Unit = {}
override var widgetNameChanged: (String) -> Unit = {}
override var onSettingsClicked: () -> Unit = {}
override var onPackageMatcherAdded: (String) -> Unit = {}

public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.configure_activity)
toolbar.setNavigationOnClickListener {
onConfirmClicked()
}
setupWidgetName()
setupToolbar()
setupNewPackageMatcher()
setupPackageMatcherList()

if (savedInstanceState == null) analytics.sendScreenView(this, "Configure")
}

private fun setupWidgetName() {
textWatcher = object : TextWatcher {
override fun afterTextChanged(text: Editable) {
widgetNameChanged(text.toString())
private fun setupToolbar() {
toolbar.setNavigationOnClickListener {
onConfirmClicked()
}
toolbar.inflateMenu(R.menu.configure_menu)
toolbar.setOnMenuItemClickListener { item ->
when (item.itemId) {
R.id.settings -> onSettingsClicked()
}

override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) =
Unit

override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) = Unit
true
}
configureWidgetName.addTextChangedListener(textWatcher)
}

private fun setupNewPackageMatcher() {
adapter = ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1)
configureNewPackageMatcher.setAdapter(adapter)

val onPackageMatcherAdded: (String) -> Unit = {
onPackageMatcherAdded(it).also { _ ->
onPackageMatcherAdded(it).also {
configureNewPackageMatcher.text = null
}
}
Expand All @@ -80,8 +79,8 @@ internal class ConfigureActivity : DaggerAppCompatActivity(), ConfigureView {
configurePackageMatcherList.adapter = packageMatcherListAdapter
}

override fun setWidgetName(widgetName: String) {
configureWidgetName.setText(widgetName)
override fun updateWidgetPreview(widgetListData: WidgetListData) {
widgetPreview.updateWidgetPreview(configureWidgetPreview, widgetListData)
}

override fun setFilters(filters: List<String>) {
Expand All @@ -105,27 +104,14 @@ internal class ConfigureActivity : DaggerAppCompatActivity(), ConfigureView {
presenter.bind(this)
}

override fun onDestroy() {
configureWidgetName.removeTextChangedListener(textWatcher)
super.onDestroy()
}

val configurePin: ConfigurePinning
get() = intent.getBooleanExtra(EXTRA_SHOULD_PIN, false)

companion object {

private const val EXTRA_SHOULD_PIN = "EXTRA_SHOULD_PIN"

fun createIntent(context: Context, appWidgetId: Int): Intent {
return Intent(context, ConfigureActivity::class.java)
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
}

@RequiresApi(O)
fun createIntentForPinning(context: Context): Intent {
return Intent(context, ConfigureActivity::class.java)
.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1)
.setData(Uri.parse("devwidget://configure?appWidgetId=-1"))
.putExtra(EXTRA_SHOULD_PIN, true)
}
}
Expand Down
Loading

0 comments on commit 77ce3b4

Please sign in to comment.