Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
Project: Optimize Code
Browse files Browse the repository at this point in the history
Signed-off-by: Fung Go <fython@163.com>
  • Loading branch information
fython committed Jan 15, 2017
1 parent 20e7925 commit dcdca38
Show file tree
Hide file tree
Showing 55 changed files with 92 additions and 83 deletions.
13 changes: 10 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ android {
applicationId "info.papdt.blackblub"
minSdkVersion 21
targetSdkVersion 25
versionCode 7
versionName "1.1.1"
versionCode 8
versionName "1.2.0"
}
buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

debug {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keep class cyanogenmod.** { *; }
-dontwarn cyanogenmod.app.**
-dontobfuscate
-dontwarn cyanogenmod.**
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

<application
android:allowBackup="true"
android:fullBackupContent="@xml/full_backup_contents"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_circle"
android:label="@string/app_name"
android:persistent="true"
android:supportsRtl="true"
android:theme="@style/AppTheme.Light"
tools:ignore="ManifestResource">
tools:ignore="ManifestResource,UnusedAttribute">
<activity
android:name=".ui.LaunchActivity"
android:finishOnTaskLaunch="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public BallState getState() {
return state;
}

public static enum BallState {
public enum BallState {
RELEASE, PRESS, MOVE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import android.content.Context;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.view.View;
import com.github.glomadrian.materialanimatedswitch.Utils;
import com.github.glomadrian.materialanimatedswitch.observer.BallFinishObservable;
import com.github.glomadrian.materialanimatedswitch.observer.BallMoveObservable;

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/info/papdt/blackblub/ui/LaunchActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package info.papdt.blackblub.ui;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
Expand Down Expand Up @@ -349,6 +350,7 @@ public void onReceive(Context context, Intent intent) {

}

@SuppressLint("HandlerLeak")
private static Handler mHandler = new Handler() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public long getItemId(int position) {
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list_mode, null);
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list_mode, parent, false);
holder = new ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.title);
holder.description = (TextView) convertView.findViewById(R.id.description);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package info.papdt.blackblub.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

@SuppressLint("CommitPrefEdits")
public class NightScreenSettings {

public static final String PREFERENCES_NAME = "settings";
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/info/papdt/blackblub/utils/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import info.papdt.blackblub.C;
import info.papdt.blackblub.R;
import info.papdt.blackblub.receiver.TileReceiver;
import info.papdt.blackblub.services.MaskService;

@SuppressWarnings("unchecked")
public class Utility {

public static final int CM_TILE_CODE = 1001;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public interface OnProgressChangeListener {
* @param value the new value
* @param fromUser if the change was made from the user or not (i.e. the developer calling {@link #setProgress(int)}
*/
public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser);
void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser);

public void onStartTrackingTouch(DiscreteSeekBar seekBar);
void onStartTrackingTouch(DiscreteSeekBar seekBar);

public void onStopTrackingTouch(DiscreteSeekBar seekBar);
void onStopTrackingTouch(DiscreteSeekBar seekBar);
}

/**
Expand Down Expand Up @@ -270,6 +270,18 @@ public DiscreteSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
if (!editMode) {
mIndicator = new PopupIndicator(context, attrs, defStyleAttr, convertValueToMessage(mMax),
thumbSize, thumbSize + mAddedTouchBounds + separation);
MarkerDrawable.MarkerAnimationListener mFloaterListener = new MarkerDrawable.MarkerAnimationListener() {
@Override
public void onClosingComplete() {
mThumb.animateToNormal();
}

@Override
public void onOpeningComplete() {

}

};
mIndicator.setListener(mFloaterListener);
}
a.recycle();
Expand Down Expand Up @@ -980,19 +992,6 @@ private void hideFloater() {
}
}

private MarkerDrawable.MarkerAnimationListener mFloaterListener = new MarkerDrawable.MarkerAnimationListener() {
@Override
public void onClosingComplete() {
mThumb.animateToNormal();
}

@Override
public void onOpeningComplete() {

}

};

@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
public abstract class AnimatorCompat {
public interface AnimationFrameUpdateListener {
public void onAnimationFrame(float currentValue);
void onAnimationFrame(float currentValue);
}

AnimatorCompat() {
Expand All @@ -51,7 +51,7 @@ public interface AnimationFrameUpdateListener {

public abstract void start();

public static final AnimatorCompat create(float start, float end, AnimationFrameUpdateListener listener) {
public static AnimatorCompat create(float start, float end, AnimationFrameUpdateListener listener) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return new AnimatorCompatV11(start, end, listener);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,10 @@ public static void setTextDirection(TextView textView, int textDirection) {
}

public static boolean isInScrollingContainer(ViewParent p) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
return SeekBarCompatDontCrash.isInScrollingContainer(p);
}
return false;
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && SeekBarCompatDontCrash.isInScrollingContainer(p);
}

public static boolean isHardwareAccelerated(View view) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return SeekBarCompatDontCrash.isHardwareAccelerated(view);
}
return false;
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && SeekBarCompatDontCrash.isHardwareAccelerated(view);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ private void computePath(Rect bounds) {
int totalSize = Math.min(bounds.width(), bounds.height());

float initial = mClosedStateSize;
float destination = totalSize;
float currentSize = initial + (destination - initial) * currentScale;
float currentSize = initial + ((float) totalSize - initial) * currentScale;

float halfSize = currentSize / 2f;
float inverseScale = 1f - currentScale;
Expand Down Expand Up @@ -242,8 +241,8 @@ private static int blendColors(int color1, int color2, float factor) {
* This is the "poor's man" AnimatorListener for this Drawable
*/
public interface MarkerAnimationListener {
public void onClosingComplete();
void onClosingComplete();

public void onOpeningComplete();
void onOpeningComplete();
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/res/drawable-xhdpi/ic_brightness_2_white_36dp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/res/drawable-xhdpi/ic_wb_sunny_white_36dp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xxhdpi/ic_brightness_2_white_36dp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/res/drawable-xxhdpi/ic_wb_sunny_white_36dp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xxxhdpi/ic_brightness_2_white_36dp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified app/src/main/res/drawable-xxxhdpi/ic_qs_night_mode_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xxxhdpi/ic_qs_night_mode_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xxxhdpi/ic_shortcut_switch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified app/src/main/res/drawable-xxxhdpi/ic_wb_sunny_white_36dp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/ic_logo_teal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_more_vert_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_wb_incandescent_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M3.55,18.54l1.41,1.41 1.79,-1.8 -1.41,-1.41 -1.79,1.8zM11,22.45h2L13,19.5h-2v2.95zM4,10.5L1,10.5v2h3v-2zM15,6.31L15,1.5L9,1.5v4.81C7.21,7.35 6,9.28 6,11.5c0,3.31 2.69,6 6,6s6,-2.69 6,-6c0,-2.22 -1.21,-4.15 -3,-5.19zM20,10.5v2h3v-2h-3zM17.24,18.16l1.79,1.8 1.41,-1.41 -1.8,-1.79 -1.4,1.4z"/>
</vector>
31 changes: 18 additions & 13 deletions app/src/main/res/layout/activity_setting.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_layout"
android:clickable="true"
android:foreground="@android:color/transparent"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
tools:ignore="ContentDescription">

<android.support.v7.widget.CardView
android:layout_height="wrap_content"
Expand All @@ -32,8 +34,8 @@
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="12dp"
android:layout_marginStart="24dp"
android:layout_marginEnd="12dp"
android:src="@drawable/ic_logo_teal"
android:tint="?attr/icon_tint"
android:scaleType="centerInside"/>
Expand All @@ -42,7 +44,7 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:text="@string/app_name"
android:textAppearance="@android:style/TextAppearance.Material.Medium"/>

Expand All @@ -56,7 +58,7 @@
android:layout_height="match_parent"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:layout_marginRight="12dp"
android:layout_marginEnd="12dp"
android:id="@+id/btn_menu"
android:src="@drawable/ic_more_vert_black_24dp"
android:tint="?attr/overflow_tint"
Expand Down Expand Up @@ -103,26 +105,29 @@

</FrameLayout>

<FrameLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:id="@+id/mode_view_container"
android:gravity="center"
android:background="#2a000000"
android:foreground="?android:attr/selectableItemBackground">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:id="@+id/mode_view"
android:layout_marginEnd="16dp"
android:text="@string/mode_text_no_permission"
android:drawableRight="@drawable/ic_chevron_right_black_24dp"
android:drawablePadding="16dp"
android:textAppearance="@android:style/TextAppearance.Material"
android:drawableTint="?android:attr/textColorPrimary"/>
android:textAppearance="@android:style/TextAppearance.Material"/>

</FrameLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_chevron_right_black_24dp"
android:tint="?android:attr/textColorPrimary"/>

</LinearLayout>

</LinearLayout>

Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/dialog_about.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
Expand All @@ -17,13 +18,14 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:src="@mipmap/ic_launcher"
android:gravity="center_vertical"/>
android:gravity="center_vertical"
tools:ignore="ContentDescription"/>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:orientation="vertical"
android:layout_gravity="center_vertical">

Expand Down
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary file not shown.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher_circle.png
1 change: 0 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<string name="app_name">Night Screen</string>

<string name="action_about">Acerca de</string>
<string name="action_overlay_system">Cubrir la barra de estado</string>
<string name="action_dark_theme">Tema oscuro</string>

<string name="text_light">CLARO</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<string name="shortcut_label_switch">Activer</string>

<string name="action_about">À propos</string>
<string name="action_overlay_system">Couvrir la barre d\'état</string>
<string name="action_dark_theme">Thème sombre</string>

<string name="text_light">CLAIR</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<string name="app_name">Nattskärm</string>

<string name="action_about">Om</string>
<string name="action_overlay_system">Täck över statusfältet</string>
<string name="action_dark_theme">Mörkt tema</string>

<string name="text_light">LJUST</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<string name="app_name">Night Screen</string>

<string name="action_about">Hakkında</string>
<string name="action_overlay_system">Durum çubuğunu kapla.</string>
<string name="action_dark_theme">Karanlık Tema</string>

<string name="text_light">AYDINLIK</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<string name="app_name">夜间屏幕</string>

<string name="action_about">关于</string>
<string name="action_overlay_system">覆盖系统状态栏</string>
<string name="action_dark_theme">暗色主题</string>

<string name="text_light">亮</string>
Expand Down
Loading

0 comments on commit dcdca38

Please sign in to comment.