diff options
Diffstat (limited to 'app')
11 files changed, 86 insertions, 33 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8f00a41d..6a6f71ba 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -93,6 +93,9 @@ <activity android:name=".LoginActivity" android:theme="@style/AppTheme.NoActionBar" /> + <activity + android:name=".SelectorActivity" + android:theme="@style/AppTheme.NoActionBar" /> <receiver android:name=".services.NotificationReceiver" diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt index 025b9001..0e5c9915 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt @@ -42,7 +42,7 @@ class MainActivity : AppCompatActivity() { lateinit var drawer: Drawer lateinit var drawerHeader: AccountHeader var titleDisposable: Disposable? = null - var refreshObservable = PublishSubject.create<Unit>().observeOn(AndroidSchedulers.mainThread()) + var refreshObservable = PublishSubject.create<Boolean>() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -135,6 +135,10 @@ class MainActivity : AppCompatActivity() { } } + fun refreshAll() { + refreshObservable.onNext(true) + } + override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_main, menu) return true diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt index 11db1a67..f293c3d3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt @@ -2,9 +2,11 @@ package com.pitchedapps.frost import android.os.Bundle import android.support.v7.app.AppCompatActivity +import android.support.v7.widget.GridLayoutManager import android.support.v7.widget.RecyclerView import butterknife.ButterKnife import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter +import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.bindView import com.pitchedapps.frost.utils.cookies import com.pitchedapps.frost.views.AccountItem @@ -21,7 +23,9 @@ class SelectorActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_selector) ButterKnife.bind(this) + recycler.layoutManager = GridLayoutManager(this, 2) recycler.adapter = adapter + L.d("Selector ${cookies()}") adapter.add(cookies().map { AccountItem(it) }) adapter.add(AccountItem()) // add account } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt index 04056043..16860cc5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.support.v7.app.AppCompatActivity import com.pitchedapps.frost.dbflow.loadFbCookiesAsync import com.pitchedapps.frost.utils.L +import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.launchNewTask /** @@ -17,10 +18,12 @@ class StartActivity : AppCompatActivity() { loadFbCookiesAsync { cookies -> L.d("Cookies loaded ${System.currentTimeMillis()} $cookies") - if (cookies.isNotEmpty()) - launchNewTask(MainActivity::class.java, ArrayList(cookies)) - else - launchNewTask(LoginActivity::class.java) + if (cookies.isNotEmpty()) { + if (Prefs.userId != Prefs.userIdDefault) + launchNewTask(MainActivity::class.java, ArrayList(cookies)) + else + launchNewTask(SelectorActivity::class.java, ArrayList(cookies)) + } else launchNewTask(LoginActivity::class.java) } } }
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt index e8fb5a21..0542722f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt @@ -11,6 +11,7 @@ import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.putString import com.pitchedapps.frost.web.FrostWebView import com.pitchedapps.frost.web.FrostWebViewCore +import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable /** @@ -18,14 +19,14 @@ import io.reactivex.disposables.Disposable */ -class WebFragment:Fragment() { +class WebFragment : Fragment() { companion object { private const val ARG_URL = "arg_url" fun newInstance(url: String) = WebFragment().putString(ARG_URL, url) } -// val refresh: SwipeRefreshLayout by lazy { frostWebView.refresh } + // val refresh: SwipeRefreshLayout by lazy { frostWebView.refresh } val web: FrostWebViewCore by lazy { frostWebView.web } lateinit var url: String lateinit private var frostWebView: FrostWebView @@ -65,8 +66,9 @@ class WebFragment:Fragment() { super.onAttach(context) refreshDisposable?.dispose() if (context is MainActivity) - refreshDisposable = context.refreshObservable.subscribe { - web.clearHistory() + refreshDisposable = context.refreshObservable.observeOn(AndroidSchedulers.mainThread()).subscribe { + clearHistory -> + if (clearHistory) web.clearHistory() web.loadBaseUrl() } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/glide/CircleTransformation.kt b/app/src/main/kotlin/com/pitchedapps/frost/glide/CircleTransformation.kt new file mode 100644 index 00000000..c37d7487 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/glide/CircleTransformation.kt @@ -0,0 +1,19 @@ +package com.pitchedapps.frost.glide + +import android.graphics.Bitmap +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation +import java.security.MessageDigest + +/** + * Created by Allan Wang on 2017-06-06. + */ +class CircleTransformation: BitmapTransformation() { + override fun updateDiskCacheKey(messageDigest: MessageDigest?) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun transform(pool: BitmapPool, toTransform: Bitmap, outWidth: Int, outHeight: Int): Bitmap { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +}
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt index 5a17fa8f..e0e33e79 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt @@ -1,5 +1,6 @@ package com.pitchedapps.frost.views +import android.graphics.Bitmap import android.graphics.drawable.Drawable import android.support.v7.widget.AppCompatTextView import android.support.v7.widget.RecyclerView @@ -8,8 +9,11 @@ import android.widget.ImageView import butterknife.ButterKnife import com.bumptech.glide.Glide import com.bumptech.glide.load.DataSource +import com.bumptech.glide.load.Transformation import com.bumptech.glide.load.engine.GlideException +import com.bumptech.glide.load.resource.bitmap.CircleCrop import com.bumptech.glide.request.RequestListener +import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.target.Target import com.mikepenz.fastadapter.items.AbstractItem import com.pitchedapps.frost.R @@ -36,7 +40,8 @@ class AccountItem(val id: Long, val name: String) : AbstractItem<AccountItem, Ac text.visibility = View.INVISIBLE if (id != -1L) { text.text = name - Glide.with(itemView).load(PROFILE_PICTURE_URL(id)).listener(object : RequestListener<Drawable> { + val options = RequestOptions().transform(CircleCrop()) + Glide.with(itemView).load(PROFILE_PICTURE_URL(id)).apply(options).listener(object : RequestListener<Drawable> { override fun onResourceReady(resource: Drawable?, model: Any?, target: Target<Drawable>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean { text.fadeIn() return false @@ -48,6 +53,7 @@ class AccountItem(val id: Long, val name: String) : AbstractItem<AccountItem, Ac } }).into(image) } else { + text.visibility = View.VISIBLE text.text = itemView.context.getString(R.string.add_account) //todo add plus image } diff --git a/app/src/main/res/layout/activity_selector.xml b/app/src/main/res/layout/activity_selector.xml index f238d2ff..e7332925 100644 --- a/app/src/main/res/layout/activity_selector.xml +++ b/app/src/main/res/layout/activity_selector.xml @@ -4,17 +4,20 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginBottom="@dimen/activity_vertical_margin" - android:layout_marginEnd="@dimen/activity_horizontal_margin" - android:layout_marginStart="@dimen/activity_horizontal_margin" - android:layout_marginTop="@dimen/activity_vertical_margin"> + android:background="@color/facebook_blue" + android:paddingBottom="@dimen/activity_vertical_margin" + android:paddingEnd="@dimen/activity_horizontal_margin" + android:paddingStart="@dimen/activity_horizontal_margin" + android:paddingTop="@dimen/activity_vertical_margin"> <android.support.v7.widget.AppCompatTextView android:id="@+id/text_select_account" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" + android:layout_marginTop="@dimen/activity_vertical_margin" android:text="@string/select_facebook_account" + android:textColor="@android:color/white" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" @@ -25,23 +28,25 @@ <android.support.v7.widget.RecyclerView android:id="@+id/selector_recycler" android:layout_width="wrap_content" - android:layout_height="0dp" + android:layout_height="wrap_content" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" - app:layout_constraintStart_toStartOf="parent" + app:layout_constraintStart_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/text_select_account" + app:layout_constraintVertical_bias="0.3" tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteY="0dp" /> - <android.support.v7.widget.AppCompatTextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" - android:text="@string/select_facebook_account" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.5" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/selector_recycler" - tools:layout_editor_absoluteX="8dp" - tools:layout_editor_absoluteY="0dp" /> + <!--<android.support.v7.widget.AppCompatTextView--> + <!--android:layout_width="wrap_content"--> + <!--android:layout_height="wrap_content"--> + <!--android:layout_gravity="center_horizontal"--> + <!--android:text="@string/select_facebook_account"--> + <!--app:layout_constraintEnd_toEndOf="parent"--> + <!--app:layout_constraintHorizontal_bias="0.5"--> + <!--app:layout_constraintStart_toStartOf="parent"--> + <!--app:layout_constraintTop_toBottomOf="@id/selector_recycler"--> + <!--tools:layout_editor_absoluteX="8dp"--> + <!--tools:layout_editor_absoluteY="0dp" />--> </android.support.constraint.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/view_account.xml b/app/src/main/res/layout/view_account.xml index 676b46d6..92486184 100644 --- a/app/src/main/res/layout/view_account.xml +++ b/app/src/main/res/layout/view_account.xml @@ -7,12 +7,18 @@ <ImageView android:id="@+id/account_image" - android:layout_width="200dp" - android:layout_height="200dp" /> + android:layout_width="@dimen/account_image_size" + android:layout_height="@dimen/account_image_size" /> + + <android.support.v4.widget.Space + android:layout_width="1dp" + android:layout_height="20dp" /> <android.support.v7.widget.AppCompatTextView android:id="@+id/account_text" - android:layout_width="200dp" + android:layout_width="@dimen/account_image_size" android:layout_height="wrap_content" - android:maxLines="1" /> + android:maxLines="1" + android:textAlignment="center" + android:textColor="@android:color/white" /> </LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 2215743c..0a058ccf 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <color name="colorPrimary">#3F51B5</color> - <color name="colorPrimaryDark">#303F9F</color> + <color name="colorPrimary">@color/facebook_blue</color> + <color name="colorPrimaryDark">@color/facebook_blue_dark</color> <color name="colorAccent">#FF4081</color> <color name="splashBackground">@color/facebook_blue</color> <color name="facebook_blue">#3b5998</color> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 6881e351..24bba22f 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -9,5 +9,6 @@ <dimen name="appbar_padding_top">8dp</dimen> <dimen name="splash_logo">16dp</dimen> <dimen name="progress_bar_height">1dip</dimen> + <dimen name="account_image_size">100dp</dimen> </resources> |