Broken minidrawer draft
This commit is contained in:
@@ -44,6 +44,7 @@ libraryDependencies ++=
|
||||
"com.google.android.gms" % "play-services-analytics" % "10.0.1" ::
|
||||
"com.google.android.gms" % "play-services-gcm" % "10.0.1" ::
|
||||
"com.j256.ormlite" % "ormlite-android" % "5.0" ::
|
||||
"com.mikepenz" % "crossfader" % "1.5.0" ::
|
||||
"com.mikepenz" % "fastadapter" % "2.1.5" ::
|
||||
"com.mikepenz" % "iconics-core" % "2.8.2" ::
|
||||
"com.mikepenz" % "materialdrawer" % "5.8.1" ::
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:bounded_width="480dp"
|
||||
app:bounded_width="@dimen/profile_item_max_width"
|
||||
android:id="@+id/indicator">
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="profile_item_max_width">480dp</dimen>
|
||||
<!-- TODO: Remove when this issue is fixed: https://github.com/JorgeCastilloPrz/FABProgressCircle/issues/19 -->
|
||||
<dimen name="fab_margin_top">-44dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -45,6 +45,9 @@ import com.github.shadowsocks.ShadowsocksApplication.app
|
||||
import com.github.shadowsocks.aidl.IShadowsocksServiceCallback
|
||||
import com.github.shadowsocks.utils.CloseUtils.autoDisconnect
|
||||
import com.github.shadowsocks.utils._
|
||||
import com.mikepenz.crossfader.Crossfader
|
||||
import com.mikepenz.crossfader.view.CrossFadeSlidingPaneLayout
|
||||
import com.mikepenz.materialdrawer.interfaces.ICrossfader
|
||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem
|
||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem
|
||||
import com.mikepenz.materialdrawer.{Drawer, DrawerBuilder}
|
||||
@@ -67,6 +70,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
|
||||
private val handler = new Handler()
|
||||
private var fab: FloatingActionButton = _
|
||||
private var fabProgressCircle: FABProgressCircle = _
|
||||
private var crossfader: Crossfader[CrossFadeSlidingPaneLayout] = _
|
||||
var drawer: Drawer = _
|
||||
|
||||
private var testCount: Int = _
|
||||
@@ -173,8 +177,9 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
|
||||
override def onCreate(savedInstanceState: Bundle) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.layout_main)
|
||||
drawer = new DrawerBuilder()
|
||||
val drawerBuilder = new DrawerBuilder()
|
||||
.withActivity(this)
|
||||
.withTranslucentStatusBar(true)
|
||||
.withHeader(R.layout.layout_header)
|
||||
.addDrawerItems(
|
||||
new PrimaryDrawerItem()
|
||||
@@ -204,7 +209,21 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
|
||||
.withOnDrawerItemClickListener(this)
|
||||
.withActionBarDrawerToggle(true)
|
||||
.withSavedInstance(savedInstanceState)
|
||||
.build()
|
||||
val miniDrawerWidth = getResources.getDimension(R.dimen.material_mini_drawer_item)
|
||||
if (getResources.getDisplayMetrics.widthPixels >=
|
||||
getResources.getDimension(R.dimen.profile_item_max_width) + miniDrawerWidth) {
|
||||
drawer = drawerBuilder.withGenerateMiniDrawer(true).buildView()
|
||||
crossfader = new Crossfader[CrossFadeSlidingPaneLayout]()
|
||||
crossfader.withContent(findViewById(android.R.id.content))
|
||||
.withFirst(drawer.getSlider, getResources.getDimensionPixelSize(R.dimen.material_drawer_width))
|
||||
.withSecond(drawer.getMiniDrawer.build(this), miniDrawerWidth.toInt)
|
||||
.withSavedInstance(savedInstanceState)
|
||||
.build()
|
||||
drawer.getMiniDrawer.withCrossFader(new ICrossfader { // a wrapper is needed
|
||||
def isCrossfaded: Boolean = crossfader.isCrossFaded
|
||||
def crossfade(): Unit = crossfader.crossFade()
|
||||
})
|
||||
} else drawer = drawerBuilder.build()
|
||||
|
||||
val header = drawer.getHeader
|
||||
val title = header.findViewById(R.id.drawer_title).asInstanceOf[TextView]
|
||||
@@ -368,6 +387,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
|
||||
override def onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
drawer.saveInstanceState(outState)
|
||||
if (crossfader != null) crossfader.saveInstanceState(outState)
|
||||
}
|
||||
|
||||
override def onDestroy() {
|
||||
|
||||
@@ -32,7 +32,9 @@ class ToolbarFragment extends Fragment {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
toolbar = view.findViewById(R.id.toolbar).asInstanceOf[Toolbar]
|
||||
val activity = getActivity.asInstanceOf[MainActivity]
|
||||
activity.drawer.setToolbar(activity, toolbar, true)
|
||||
try activity.drawer.setToolbar(activity, toolbar, true) catch {
|
||||
case _: Exception => // ignore for now
|
||||
}
|
||||
}
|
||||
|
||||
def onTrafficUpdated(txRate: Long, rxRate: Long, txTotal: Long, rxTotal: Long): Unit = ()
|
||||
|
||||
Reference in New Issue
Block a user