Skip to content

Commit

Permalink
fix accent color settings
Browse files Browse the repository at this point in the history
  • Loading branch information
1hakr committed Feb 26, 2017
1 parent e7e51f8 commit 419112b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 27 deletions.
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
applicationVariants.all { variant ->
variant.outputs.each { output ->
def newApkName = "${parent.name}-${output.baseName}-${variant.versionName}.apk"
output.outputFile = new File(output.outputFile.parent, newApkName)
}

applicationVariants.all { variant ->
variant.outputs.each { output ->
def newApkName = "${parent.name}-${output.baseName}-${variant.versionName}.apk"
output.outputFile = new File(output.outputFile.parent, newApkName)
}
}

defaultConfig {
Expand All @@ -26,7 +26,7 @@ android {
minifyEnabled false
shrinkResources false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard/proguard-project.pro',
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard/proguard-project.pro',
'proguard/proguard-google-play-services.pro'
}
release {
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/dev/dworks/apps/anexplorer/AboutActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.ShareCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.ColorUtils;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -54,7 +54,8 @@ protected void onCreate(Bundle savedInstanceState) {
//((LinearLayout.LayoutParams) mToolbar.getLayoutParams()).setMargins(0, getStatusBarHeight(this), 0, 0);
mToolbar.setPadding(0, getStatusBarHeight(this), 0, 0);
}
int color = SettingsActivity.getPrimaryColor(this);
int color = SettingsActivity.getPrimaryColor();
mToolbar.setBackgroundColor(color);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(null);
Expand All @@ -70,8 +71,10 @@ public String getTag() {

private void initControls() {

int accentColor = ColorUtils.setAlphaComponent(SettingsActivity.getAccentColor(), 200);

TextView logo = (TextView)findViewById(R.id.logo);
logo.setTextColor(SettingsActivity.getAccentColor());
logo.setTextColor(accentColor);
String header = logo.getText() + getSuffix() + " v" + BuildConfig.VERSION_NAME;
logo.setText(header);

Expand Down Expand Up @@ -155,7 +158,7 @@ public void onClick(View view) {
}

public void setUpDefaultStatusBar() {
int color = ContextCompat.getColor(this, R.color.material_blue_grey_800);
int color = Utils.getStatusBarColor(SettingsActivity.getPrimaryColor());
if(Utils.hasLollipop()){
getWindow().setStatusBarColor(color);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class ConnectionsFragment extends ListFragment implements View.OnClickLis
private CompatTextView mEmptyView;
private FloatingActionButton fab;
private RootInfo mConnectionsRoot;
private int mLastShowAccentColor;

public static void show(FragmentManager fm) {
final ConnectionsFragment fragment = new ConnectionsFragment();
Expand Down Expand Up @@ -92,11 +93,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
public void onViewCreated(View view, Bundle savedInstanceState) {
final Resources res = getActivity().getResources();

int defaultColor = SettingsActivity.getPrimaryColor();
int accentColor = SettingsActivity.getAccentColor();

fab = (FloatingActionButton)view.findViewById(R.id.fab);
fab.setBackgroundTintList(ColorStateList.valueOf(accentColor));
fab.setOnClickListener(this);
if(isTelevision()){
fab.setVisibility(View.GONE);
Expand All @@ -122,6 +119,15 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
}
}

@Override
public void onResume() {
super.onResume();
int accentColor = SettingsActivity.getAccentColor();
if ((mLastShowAccentColor != 0 && mLastShowAccentColor == accentColor))
return;
fab.setBackgroundTintList(ColorStateList.valueOf(accentColor));
}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public class DirectoryFragment extends ListFragment {
private boolean mLastShowFolderSize = false;
private boolean mLastShowThumbnail = false;
private int mLastShowColor = 0;
private int mLastShowAccentColor = 0;
private boolean mLastShowHiddenFiles = false;

private boolean mHideGridTitles = false;
Expand Down Expand Up @@ -473,12 +474,14 @@ private void updateDisplayState() {
final State state = getDisplayState(this);

mDefaultColor = SettingsActivity.getPrimaryColor(getActivity());
int accentColor = SettingsActivity.getAccentColor();
if (mLastMode == state.derivedMode && mLastSortOrder == state.derivedSortOrder
&& mLastShowSize == state.showSize
&& mLastShowFolderSize == state.showFolderSize
&& mLastShowThumbnail == state.showThumbnail
&& mLastShowHiddenFiles == state.showHiddenFiles
&& (mLastShowColor != 0 && mLastShowColor == mDefaultColor))
&& (mLastShowColor != 0 && mLastShowColor == mDefaultColor)
&& (mLastShowAccentColor != 0 && mLastShowAccentColor == accentColor))
return;
boolean refreshData = mLastShowHiddenFiles != state.showHiddenFiles;
mLastMode = state.derivedMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult resul
if (!isAdded())
return;
if(null == result.cursor || (null != result.cursor && result.cursor.getCount() == 0)) {
//recents_container.setVisibility(View.GONE);
recents_container.setVisibility(View.GONE);
} else {
//recents_container.setVisibility(View.VISIBLE);
mRecentsAdapter.swapCursor(new LimitCursorWrapper(result.cursor, MAX_RECENT_COUNT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import static dev.dworks.apps.anexplorer.setting.SettingsActivity.KEY_PRIMARY_COLOR;
import static dev.dworks.apps.anexplorer.setting.SettingsActivity.KEY_THEME_STYLE;

public class ThemePreferenceFragment extends PreferenceFragment implements OnPreferenceChangeListener{
public class ThemePreferenceFragment extends PreferenceFragment
implements OnPreferenceChangeListener, Preference.OnPreferenceClickListener{

public ThemePreferenceFragment() {
}
Expand All @@ -23,18 +24,13 @@ public void onCreate(Bundle savedInstanceState) {

Preference preferencePrimaryColor = findPreference(KEY_PRIMARY_COLOR);
preferencePrimaryColor.setOnPreferenceChangeListener(this);
preferencePrimaryColor.setOnPreferenceClickListener(this);

Preference preferenceAccentColor = findPreference(KEY_ACCENT_COLOR);
preferenceAccentColor.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
SettingsActivity.logSettingEvent(preference.getKey());
return false;
}
});
findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);

Preference preferenceThemeStyle = findPreference(KEY_THEME_STYLE);
preferenceThemeStyle.setOnPreferenceChangeListener(this);
preferenceThemeStyle.setOnPreferenceClickListener(this);

}

Expand All @@ -45,4 +41,10 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
getActivity().recreate();
return true;
}

@Override
public boolean onPreferenceClick(Preference preference) {
SettingsActivity.logSettingEvent(preference.getKey());
return false;
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_connections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:layout_margin="24dp"
app:layout_anchor="@id/list"
app:fabGravity="bottom_end"
app:layout_anchorGravity="bottom|right|end"
Expand Down

0 comments on commit 419112b

Please sign in to comment.