Use stock FAB; Log monospace; Fixes

This commit is contained in:
topjohnwu 2017-04-24 21:52:23 +08:00
parent ae88d3054d
commit 47b13aa5ea
10 changed files with 29 additions and 157 deletions

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,7 +13,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import com.github.clans.fab.FloatingActionButton;
import com.topjohnwu.magisk.adapters.ModulesAdapter; import com.topjohnwu.magisk.adapters.ModulesAdapter;
import com.topjohnwu.magisk.asyncs.FlashZip; import com.topjohnwu.magisk.asyncs.FlashZip;
import com.topjohnwu.magisk.asyncs.LoadModules; import com.topjohnwu.magisk.asyncs.LoadModules;

View File

@ -1,114 +0,0 @@
package com.topjohnwu.magisk.utils;
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.util.AttributeSet;
import android.view.View;
import com.github.clans.fab.FloatingActionMenu;
import java.util.List;
/**
* Created by Matteo on 08/08/2015.
*
* Floating Action Menu Behavior for Clans.FloatingActionButton
* https://github.com/Clans/FloatingActionButton/
*
* Use this behavior as your app:layout_behavior attribute in your Floating Action Menu to use the
* FabMenu in a Coordinator Layout.
*
* Remember to use the correct namespace for the fab:
* xmlns:app="http://schemas.android.com/apk/res-auto"
*/
public class FABBehavior extends CoordinatorLayout.Behavior<View> {
private float mTranslationY;
public FABBehavior(Context context, AttributeSet attrs) {
super();
}
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
return dependency instanceof Snackbar.SnackbarLayout;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
if (dependency instanceof Snackbar.SnackbarLayout) {
updateTranslation(parent, child);
}
return false;
}
@Override
public void onDependentViewRemoved(CoordinatorLayout parent, View child, View dependency) {
if (dependency instanceof Snackbar.SnackbarLayout) {
revertTranslation(child);
}
}
private void updateTranslation(CoordinatorLayout parent, View child) {
float translationY = getTranslationY(parent, child);
if (translationY != mTranslationY) {
ViewPropertyAnimatorCompat anim = ViewCompat.animate(child);
anim.cancel();
anim.translationY(translationY).setDuration(100);
mTranslationY = translationY;
}
}
private void revertTranslation(View child) {
if (mTranslationY != 0) {
ViewPropertyAnimatorCompat anim = ViewCompat.animate(child);
anim.cancel();
anim.translationY(0).setDuration(100);
mTranslationY = 0;
}
}
private float getTranslationY(CoordinatorLayout parent, View child) {
float minOffset = 0.0F;
List<View> dependencies = parent.getDependencies(child);
int i = 0;
for (int z = dependencies.size(); i < z; ++i) {
View view = dependencies.get(i);
if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(child, view)) {
minOffset = Math.min(minOffset, ViewCompat.getTranslationY(view) - (float) view.getHeight());
}
}
return minOffset;
}
/**
* onStartNestedScroll and onNestedScroll will hide/show the FabMenu when a scroll is detected.
*/
@Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child,
View directTargetChild, View target, int nestedScrollAxes) {
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL ||
super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target,
nestedScrollAxes);
}
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, View child, View target,
int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed,
dyUnconsumed);
FloatingActionMenu fabMenu = (FloatingActionMenu) child;
if (dyConsumed > 0 && !fabMenu.isMenuButtonHidden()) {
fabMenu.hideMenuButton(true);
} else if (dyConsumed < 0 && fabMenu.isMenuButtonHidden()) {
fabMenu.showMenuButton(true);
}
}
}

View File

@ -13,28 +13,28 @@ public class Logger {
} }
public static void error(String msg) { public static void error(String msg) {
Log.e(TAG, "ERROR: " + msg); Log.e(TAG, "MANAGERERROR: " + msg);
} }
public static void dev(String msg, Object... args) { public static void dev(String msg, Object... args) {
if (MagiskManager.devLogging) { if (MagiskManager.devLogging) {
if (args.length == 1 && args[0] instanceof Throwable) { if (args.length == 1 && args[0] instanceof Throwable) {
Log.d(TAG, "DEV: " + msg, (Throwable) args[0]); Log.d(TAG, "MANAGER: " + msg, (Throwable) args[0]);
} else { } else {
Log.d(TAG, "DEV: " + String.format(msg, args)); Log.d(TAG, "MANAGER: " + String.format(msg, args));
} }
} }
} }
public static void dev(String msg) { public static void dev(String msg) {
if (MagiskManager.devLogging) { if (MagiskManager.devLogging) {
Log.d(TAG, "DEV: " + msg); Log.d(TAG, "MANAGER: " + msg);
} }
} }
public static void shell(boolean root, String msg) { public static void shell(boolean root, String msg) {
if (MagiskManager.shellLogging) { if (MagiskManager.shellLogging) {
Log.d(root ? "SU" : "SH", msg); Log.d(TAG, root ? "MANAGERSU" : "MANAGERSH" + msg);
} }
} }
} }

View File

@ -1,6 +1,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <zlib.h> #include <zlib.h>
#include <string.h>
#include "zipadjust.h" #include "zipadjust.h"
size_t insize = 0, outsize = 0, alloc = 0; size_t insize = 0, outsize = 0, alloc = 0;

View File

@ -20,8 +20,10 @@
android:id="@+id/txtLog" android:id="@+id/txtLog"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fontFamily="monospace"
android:padding="8dp" android:padding="8dp"
android:textIsSelectable="true"/> android:textIsSelectable="true"
android:textSize="10sp" />
<ProgressBar <ProgressBar
android:id="@+id/progressBar" android:id="@+id/progressBar"

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/swipeRefreshLayout" android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
@ -22,7 +22,8 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false" android:clipToPadding="false"
android:dividerHeight="@dimen/card_divider_space" android:dividerHeight="@dimen/card_divider_space"
fab:layoutManager="android.support.v7.widget.LinearLayoutManager" /> app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
<TextView <TextView
android:id="@+id/empty_rv" android:id="@+id/empty_rv"
@ -36,39 +37,16 @@
android:textStyle="italic" android:textStyle="italic"
android:visibility="gone" /> android:visibility="gone" />
<android.support.design.widget.FloatingActionButton
<com.github.clans.fab.FloatingActionMenu android:id="@+id/fab"
android:id="@+id/fabmenu" android:layout_width="wrap_content"
android:layout_width="500dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal" android:layout_gravity="bottom|center_horizontal"
android:layout_marginEnd="113dp" android:layout_margin="@dimen/fab_padding"
android:layout_marginBottom="10dp" android:elevation="6dp"
fab:layout_behavior=".utils.FABBehavior" android:src="@drawable/ic_add"
fab:menu_fab_size="normal" tools:fabSize="normal"
fab:menu_showShadow="true" tools:pressedTranslationZ="12dp" />
fab:menu_shadowColor="#66000000"
fab:menu_shadowRadius="4dp"
fab:menu_shadowXOffset="1dp"
fab:menu_shadowYOffset="3dp"
fab:menu_colorNormal="?android:colorAccent"
fab:menu_colorPressed="?attr/colorAccentFallback"
fab:menu_animationDelayPerItem="50"
fab:menu_icon="@drawable/ic_add"
fab:menu_buttonSpacing="0dp"
fab:menu_labels_position="left" >
<com.github.clans.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/ic_archive"
fab:fab_colorNormal="?android:colorAccent"
fab:fab_colorPressed="?attr/colorAccentFallback"
fab:fab_size="mini"
fab:fab_label="@string/fab_flash_zip" />
</com.github.clans.fab.FloatingActionMenu>
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="fab_padding">24dp</dimen>
</resources>

View File

@ -11,4 +11,5 @@
<dimen name="card_textview_width">300dip</dimen> <dimen name="card_textview_width">300dip</dimen>
<dimen name="checkbox_padding">3dp</dimen> <dimen name="checkbox_padding">3dp</dimen>
<dimen name="card_appicon_size">50dp</dimen> <dimen name="card_appicon_size">50dp</dimen>
<dimen name="fab_padding">16dp</dimen>
</resources> </resources>

View File

@ -6,7 +6,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha4' classpath 'com.android.tools.build:gradle:2.4.0-alpha6'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files