Commit 04c1d4c5 authored by Gilbert Ndresaj's avatar Gilbert Ndresaj

Collumns on Landscape

parent 57a0bbbf
......@@ -230,6 +230,7 @@ public class MainActivity extends SharedMediaActivity {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
updateColumnsRvs();
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
fabCamera.setVisibility(View.GONE);
} else {
......@@ -445,21 +446,40 @@ public class MainActivity extends SharedMediaActivity {
}
private void updateColumnsRvs() {
int spanCount = SP.getInt("n_columns_folders", 2);
if ( spanCount != ((GridLayoutManager) rvAlbums.getLayoutManager()).getSpanCount()) {
rvAlbums.removeItemDecoration(rvAlbumsDecoration);
rvAlbumsDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvAlbums.addItemDecoration(rvAlbumsDecoration);
rvAlbums.setLayoutManager(new GridLayoutManager(this, spanCount));
int spanCount;
if (getResources().getConfiguration().orientation==Configuration.ORIENTATION_PORTRAIT) {
spanCount = SP.getInt("n_columns_folders", 2);
if (spanCount != ((GridLayoutManager) rvAlbums.getLayoutManager()).getSpanCount()) {
rvAlbums.removeItemDecoration(rvAlbumsDecoration);
rvAlbumsDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvAlbums.addItemDecoration(rvAlbumsDecoration);
rvAlbums.setLayoutManager(new GridLayoutManager(this, spanCount));
}
spanCount = SP.getInt("n_columns_media", 3);
if (spanCount != ((GridLayoutManager) rvMedia.getLayoutManager()).getSpanCount()) {
((GridLayoutManager) rvMedia.getLayoutManager()).getSpanCount();
rvMedia.removeItemDecoration(rvMediaDecoration);
rvMediaDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvMedia.setLayoutManager(new GridLayoutManager(getApplicationContext(), spanCount));
rvMedia.addItemDecoration(rvMediaDecoration);
}
}
spanCount = SP.getInt("n_columns_media", 3);
if (spanCount != ((GridLayoutManager) rvMedia.getLayoutManager()).getSpanCount()) {
((GridLayoutManager) rvMedia.getLayoutManager()).getSpanCount();
rvMedia.removeItemDecoration(rvMediaDecoration);
rvMediaDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvMedia.setLayoutManager(new GridLayoutManager(getApplicationContext(), spanCount));
rvMedia.addItemDecoration(rvMediaDecoration);
else {
spanCount = SP.getInt("n_columns_folders_landscape", 3);
if (spanCount != ((GridLayoutManager) rvAlbums.getLayoutManager()).getSpanCount()) {
rvAlbums.removeItemDecoration(rvAlbumsDecoration);
rvAlbumsDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvAlbums.addItemDecoration(rvAlbumsDecoration);
rvAlbums.setLayoutManager(new GridLayoutManager(this, spanCount));
}
spanCount = SP.getInt("n_columns_media_landscape", 4);
if (spanCount != ((GridLayoutManager) rvMedia.getLayoutManager()).getSpanCount()) {
((GridLayoutManager) rvMedia.getLayoutManager()).getSpanCount();
rvMedia.removeItemDecoration(rvMediaDecoration);
rvMediaDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getApplicationContext()), true);
rvMedia.setLayoutManager(new GridLayoutManager(getApplicationContext(), spanCount));
rvMedia.addItemDecoration(rvMediaDecoration);
}
}
}
......
......@@ -112,7 +112,7 @@ public class SettingsActivity extends ThemedActivity {
@Override
public void onColorSelected(int color) {
SP.putInt(getString(R.string.preference_primary_color), color);
//updateViewsWithAccentColor(color);
updateViewsWithPrimaryColor(color);
}
@Override
......@@ -136,7 +136,7 @@ public class SettingsActivity extends ThemedActivity {
@Override
public void onColorSelected(int color) {
SP.putInt(getString(R.string.preference_accent_color), color);
//updateViewsWithAccentColor(color);
updateViewsWithAccentColor(color);
}
@Override
......@@ -350,11 +350,7 @@ public class SettingsActivity extends ThemedActivity {
}
public void updateViewsWithAccentColor(int color){
txtGT.setTextColor(color);
txtTT.setTextColor(color);
txtPT.setTextColor(color);
txtVT.setTextColor(color);
txtAT.setTextColor(color);
setTextViewColor(color, txtAT, txtGT, txtPT, txtTT, txtVT);
setSwitchColor(color,
swDelayFullImage,
swNavBar,
......
......@@ -16,6 +16,7 @@ import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.SeekBar;
import android.widget.TextView;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.context.IconicsContextWrapper;
......@@ -204,6 +205,11 @@ public abstract class ThemedActivity extends AppCompatActivity implements UiElem
themeHelper.setSwitchCompactColor(switchCompat, color);
}
public void setTextViewColor(int color, TextView... textViews){
for (TextView txt: textViews)
themeHelper.setTextViewColor(txt, color);
}
public IconicsDrawable getToolbarIcon(IIcon icon){
return themeHelper.getToolbarIcon(icon);
}
......
......@@ -28,23 +28,36 @@ public class GeneralSetting extends ThemedSetting {
((TextView) dialogLayout.findViewById(R.id.folders_title)).setTextColor(getActivity().getTextColor());
((TextView) dialogLayout.findViewById(R.id.media_title)).setTextColor(getActivity().getTextColor());
((TextView) dialogLayout.findViewById(R.id.folders_title_landscape)).setTextColor(getActivity().getTextColor());
((TextView) dialogLayout.findViewById(R.id.media_title_landscape)).setTextColor(getActivity().getTextColor());
((CardView) dialogLayout.findViewById(R.id.multi_column_card)).setCardBackgroundColor(getActivity().getCardBackgroundColor());
dialogLayout.findViewById(R.id.multi_column_title).setBackgroundColor(getActivity().getPrimaryColor());
final TextView nColFolders = (TextView) dialogLayout.findViewById(R.id.n_columns_folders);
final TextView nColMedia = (TextView) dialogLayout.findViewById(R.id.n_columns_media);
final TextView nColFoldersL = (TextView) dialogLayout.findViewById(R.id.n_columns_folders_landscape);
final TextView nColMediaL = (TextView) dialogLayout.findViewById(R.id.n_columns_media_landscape);
nColFolders.setTextColor(getActivity().getSubTextColor());
nColMedia.setTextColor(getActivity().getSubTextColor());
nColFoldersL.setTextColor(getActivity().getSubTextColor());
nColMediaL.setTextColor(getActivity().getSubTextColor());
SeekBar barFolders = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_n_columns_folders);
SeekBar barMedia = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_n_columns_media);
SeekBar barFoldersL = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_n_columns_folders_landscape);
SeekBar barMediaL = (SeekBar) dialogLayout.findViewById(R.id.seek_bar_n_columns_media_landscape);
getActivity().themeSeekBar(barFolders);
getActivity().themeSeekBar(barMedia);
getActivity().themeSeekBar(barFoldersL);
getActivity().themeSeekBar(barMediaL);
///PORTRAIT
nColFolders.setText(String.valueOf(getSP().getInt("n_columns_folders", 2)));
nColMedia.setText(String.valueOf(getSP().getInt("n_columns_media", 3)));
barFolders.setProgress(getSP().getInt("n_columns_folders", 2) -1);
barMedia.setProgress(getSP().getInt("n_columns_media", 3) -1);
barMedia.setProgress(getSP().getInt("n_columns_media", 3) -2);
barFolders.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
......@@ -59,7 +72,34 @@ public class GeneralSetting extends ThemedSetting {
barMedia.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
nColMedia.setText(String.valueOf(i+1));
nColMedia.setText(String.valueOf(i+2));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
///LANDSCAPE
nColFoldersL.setText(String.valueOf(getSP().getInt("n_columns_folders_landscape", 3)));
nColMediaL.setText(String.valueOf(getSP().getInt("n_columns_media_landscape", 4)));
barFoldersL.setProgress(getSP().getInt("n_columns_folders_landscape", 3) -2);
barMediaL.setProgress(getSP().getInt("n_columns_media_landscape", 4) -3);
barFoldersL.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
nColFoldersL.setText(String.valueOf(i+2));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
barMediaL.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
nColMediaL.setText(String.valueOf(i+3));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
......@@ -72,8 +112,12 @@ public class GeneralSetting extends ThemedSetting {
public void onClick(DialogInterface dialogInterface, int i) {
int nFolders = Integer.parseInt(nColFolders.getText().toString());
int nMedia = Integer.parseInt(nColMedia.getText().toString());
int nFoldersL = Integer.parseInt(nColFoldersL.getText().toString());
int nMediaL = Integer.parseInt(nColMediaL.getText().toString());
getSP().putInt("n_columns_folders", nFolders);
getSP().putInt("n_columns_media", nMedia);
getSP().putInt("n_columns_folders_landscape", nFoldersL);
getSP().putInt("n_columns_media_landscape", nMediaL);
}
});
multiColumnDialogBuilder.setNegativeButton(getActivity().getString(R.string.cancel).toUpperCase(), null);
......
......@@ -267,6 +267,10 @@ public class ThemeHelper {
PorterDuff.Mode.MULTIPLY);
}
public void setTextViewColor(TextView txt, int color){
txt.setTextColor(color);
}
public void setScrollViewColor(ScrollView scr){
try
{
......
......@@ -114,6 +114,8 @@
<string name="insert_a_name">Insert something</string>
<string name="nothing_changed">Nothing changed!</string>
<string name="install_shortcut">Install shortcut</string>
<string name="landscape">Landscape</string>
<string name="portrait">Portrait</string>
<!--SETTINGS PREFERENCES-->
<string name="general_setting">General Setting</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment