Commit 404aac5f authored by Donald's avatar Donald

a lot of clean

parent 634bfd28
......@@ -149,7 +149,7 @@ public class SelectAlbumBuilder extends BottomSheetDialogFragment {
// if(documentFile != null){
// displayContentFolder(new File(ContentHelper.getExtSdCardPaths(getContext())[pos - 1]));
// } else {
// Toast.makeText(getContext(), getString(R.string.no_permission), Toast.LENGTH_LONG).show();
// Toast.makeText(getContext(), getString(R.string.no_permission), Toast.LENGTH_LONG).choseProvider();
// spinner.setSelection(0);
// }
// } else {
......
......@@ -474,7 +474,7 @@ public class MainActivity extends SharedMediaActivity {
// // Persist URI in shared preference so that you can use it later.
// ContentHelper.saveSdCardInfo(getApplicationContext(), treeUri);
// getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
// Toast.makeText(this, R.string.got_permission_wr_sdcard, Toast.LENGTH_SHORT).show();
// Toast.makeText(this, R.string.got_permission_wr_sdcard, Toast.LENGTH_SHORT).choseProvider();
// }
// }
// }
......@@ -493,7 +493,7 @@ public class MainActivity extends SharedMediaActivity {
// startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), REQUEST_CODE_SD_CARD_PERMISSIONS);
// }
// });
// dialogBuilder.show();
// dialogBuilder.choseProvider();
// }
private void updateSelectedStuff() {
......
......@@ -100,7 +100,7 @@ public class SingleMediaActivity extends SharedMediaActivity {
//the image is stored in the storage
album = new Album(getApplicationContext(), file);
else {
//try to show with Uri
//try to choseProvider with Uri
album = new Album(getApplicationContext(), getIntent().getData());
customUri = true;
}
......@@ -169,7 +169,7 @@ public class SingleMediaActivity extends SharedMediaActivity {
/**** Theme ****/
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setBackgroundColor(
isApplyThemeOnImgAct()
themeOnSingleImgAct()
? ColorPalette.getTransparentColor (getPrimaryColor(), getTransparency())
: ColorPalette.getTransparentColor(getDefaultThemeToolbarColor3th(), 175));
......@@ -553,7 +553,7 @@ public class SingleMediaActivity extends SharedMediaActivity {
@Override
public void setNavBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (isApplyThemeOnImgAct())
if (themeOnSingleImgAct())
if (isNavigationBarColored())
getWindow().setNavigationBarColor(ColorPalette.getTransparentColor(getPrimaryColor(), getTransparency()));
else
......@@ -566,7 +566,7 @@ public class SingleMediaActivity extends SharedMediaActivity {
@Override
protected void setStatusBarColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (isApplyThemeOnImgAct())
if (themeOnSingleImgAct())
if (isTranslucentStatusBar() && isTransparencyZero())
getWindow().setStatusBarColor(ColorPalette.getObscuredColor(getPrimaryColor()));
else
......
......@@ -13,7 +13,6 @@ import android.support.v7.widget.SwitchCompat;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.SeekBar;
......@@ -40,7 +39,7 @@ public abstract class ThemedActivity extends AppCompatActivity implements UiElem
private boolean coloredNavBar;
private boolean obscuredStatusBar;
private boolean applyThemeImgAct;
private boolean applyThemeSingleImgAct;
@Override
......@@ -63,7 +62,7 @@ public abstract class ThemedActivity extends AppCompatActivity implements UiElem
themeHelper.updateTheme();
coloredNavBar = SP.getBoolean(getString(R.string.preference_colored_nav_bar), false);
obscuredStatusBar = SP.getBoolean(getString(R.string.preference_translucent_status_bar),true);
applyThemeImgAct = SP.getBoolean(getString(R.string.preference_apply_theme_pager), true);
applyThemeSingleImgAct = SP.getBoolean(getString(R.string.preference_apply_theme_pager), true);
}
@Override
......@@ -95,13 +94,6 @@ public abstract class ThemedActivity extends AppCompatActivity implements UiElem
themeHelper.setScrollViewColor(scr);
}
@Deprecated
public void setCursorDrawableColor(EditText editText, int color) {
// TODO: 02/08/16 remove this
ThemeHelper.setCursorColor(editText, color);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setRecentApp(String text){
......@@ -120,8 +112,8 @@ public abstract class ThemedActivity extends AppCompatActivity implements UiElem
return obscuredStatusBar;
}
protected boolean isApplyThemeOnImgAct() {
return applyThemeImgAct;
public boolean themeOnSingleImgAct() {
return applyThemeSingleImgAct;
}
protected boolean isTransparencyZero() {
......@@ -149,7 +141,7 @@ public abstract class ThemedActivity extends AppCompatActivity implements UiElem
public Theme getBaseTheme(){ return themeHelper.getBaseTheme(); }
protected int getBackgroundColor(){
public int getBackgroundColor(){
return themeHelper.getBackgroundColor();
}
......@@ -197,11 +189,11 @@ public abstract class ThemedActivity extends AppCompatActivity implements UiElem
return themeHelper.getDefaultThemeToolbarColor3th();
}
protected void themeRadioButton(RadioButton radioButton) {
public void themeRadioButton(RadioButton radioButton) {
themeHelper.themeRadioButton(radioButton);
}
protected void themeCheckBox(CheckBox chk) {
public void themeCheckBox(CheckBox chk) {
themeHelper.themeCheckBox(chk);
}
......@@ -211,6 +203,13 @@ public abstract class ThemedActivity extends AppCompatActivity implements UiElem
themeHelper.setSwitchCompactColor(sw, color);
}
public void setSwitchColor(SwitchCompat sw[], int color){
for (SwitchCompat switchCompat : sw) {
themeHelper.setSwitchCompactColor(switchCompat, color);
}
}
public IconicsDrawable getToolbarIcon(IIcon icon){
return themeHelper.getToolbarIcon(icon);
}
......
......@@ -113,23 +113,14 @@ public class AlbumsAdapter extends RecyclerView.Adapter<AlbumsAdapter.ViewHolder
}
}
String albumNameHtml = "<i><font color='" + textColor + "'>" + a.getName() + "</font></i>";
String albumPhotoCountHtml = "<b><font color='" + hexAccentColor + "'>" + a.getCount() + "</font></b>" + "<font " +
"color='" + textColor + "'> " + holder.nPhotos.getContext().getString(R.string.media) + "</font>";
if (cvs.equals(CardViewStyle.COMPACT)) {
albumPhotoCountHtml = "<b><font color='" + hexAccentColor + "'>#" + a.getCount() + "</font></b>";
}
holder.llMdia.setVisibility(SP.getBoolean("show_n_photos", true) ? View.VISIBLE : View.GONE);
String albumNameHtml = "<i><font color='" + textColor + "'>" + a.getName() + "</font></i>";
String albumPhotoCountHtml = "<b><font color='" + hexAccentColor + "'>" + a.getCount() + "</font></b>";
holder.mediaLabel.setTextColor(theme.getTextColor());
holder.name.setText(StringUtils.html(albumNameHtml));
holder.nPhotos.setText(StringUtils.html(albumPhotoCountHtml));
//IMAGE COUNTER
if (!SP.getBoolean("show_n_photos", true))
holder.nPhotos.setVisibility(View.GONE);
// (a.getImagesCount() == 1 ? c.getString(R.string.singular_photo) : c.getString(R.string.plural_photos))
}
public void setOnClickListener(View.OnClickListener lis) {
......@@ -155,16 +146,18 @@ public class AlbumsAdapter extends RecyclerView.Adapter<AlbumsAdapter.ViewHolder
static class ViewHolder extends RecyclerView.ViewHolder {
ImageView picture;
View selectedIcon, layout;
TextView name, nPhotos;
View selectedIcon, layout, llMdia;
TextView name, nPhotos, mediaLabel;
ViewHolder(View itemView) {
super(itemView);
picture = (ImageView) itemView.findViewById(org.horaapps.leafpic.R.id.album_preview);
selectedIcon = itemView.findViewById(org.horaapps.leafpic.R.id.selected_icon);
llMdia = itemView.findViewById(R.id.ll_n_media);
layout = itemView.findViewById(org.horaapps.leafpic.R.id.linear_card_text);
name = (TextView) itemView.findViewById(org.horaapps.leafpic.R.id.album_name);
nPhotos = (TextView) itemView.findViewById(org.horaapps.leafpic.R.id.album_photos_count);
mediaLabel = (TextView) itemView.findViewById(R.id.album_media_label);
}
}
}
......
package org.horaapps.leafpic.settings;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.util.CardViewStyle;
import org.horaapps.leafpic.util.ColorPalette;
import org.horaapps.leafpic.util.PreferenceUtil;
import org.horaapps.leafpic.util.StringUtils;
import org.horaapps.leafpic.util.Theme;
import static org.horaapps.leafpic.util.CardViewStyle.COMPACT;
import static org.horaapps.leafpic.util.CardViewStyle.FLAT;
import static org.horaapps.leafpic.util.CardViewStyle.MATERIAL;
/**
* Created by dnld on 12/9/16.
*/
public class CardViewStyleSetting extends ThemedSetting {
public CardViewStyleSetting(ThemedActivity activity, PreferenceUtil SP) {
super(activity, SP);
}
public void show() {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
final View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_select_cardview_style, null);
TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.dialog_card_view_style_title);
((CardView) dialogLayout.findViewById(R.id.dialog_card_view_style)).setCardBackgroundColor(getActivity().getCardBackgroundColor());
dialogTitle.setBackgroundColor(getActivity().getPrimaryColor());
final RadioGroup rGroup = (RadioGroup) dialogLayout.findViewById(R.id.radio_group_card_view_style);
final CheckBox chkShowNPhots = (CheckBox) dialogLayout.findViewById(R.id.show_n_photos);
RadioButton rCompact = (RadioButton) dialogLayout.findViewById(R.id.radio_card_compact);
RadioButton rFlat = (RadioButton) dialogLayout.findViewById(R.id.radio_card_flat);
RadioButton rMaterial = (RadioButton) dialogLayout.findViewById(R.id.radio_card_material);
chkShowNPhots.setChecked(getSP().getBoolean("show_n_photos", true));
getActivity().themeRadioButton(rCompact);
getActivity().themeRadioButton(rFlat);
getActivity().themeRadioButton(rMaterial);
getActivity().themeCheckBox(chkShowNPhots);
rGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
final View v;
switch (i) {
case R.id.radio_card_compact:
v = LayoutInflater.from(getActivity()).inflate(COMPACT.getLayout(), null);
v.findViewById(R.id.linear_card_text).setBackgroundColor(ColorPalette.getTransparentColor(getActivity().getBackgroundColor(), 150));
break;
case R.id.radio_card_flat:
v = LayoutInflater.from(getActivity()).inflate(FLAT.getLayout(), null);
v.findViewById(R.id.linear_card_text).setBackgroundColor(ColorPalette.getTransparentColor(getActivity().getBackgroundColor(), 150));
break;
case R.id.radio_card_material: default:
v = LayoutInflater.from(getActivity()).inflate(MATERIAL.getLayout(), null);
v.findViewById(R.id.linear_card_text).setBackgroundColor(getActivity().getCardBackgroundColor());
break;
}
ImageView img = (ImageView) v.findViewById(org.horaapps.leafpic.R.id.album_preview);
img.setBackgroundColor(getActivity().getPrimaryColor());
Glide.with(getActivity())
.load(R.drawable.donald_header)
.into(img);
String hexPrimaryColor = ColorPalette.getHexColor(getActivity().getPrimaryColor());
String hexAccentColor = ColorPalette.getHexColor(getActivity().getAccentColor());
if (hexAccentColor.equals(hexPrimaryColor))
hexAccentColor = ColorPalette.getHexColor(ColorPalette.getDarkerColor(getActivity().getAccentColor()));
String textColor = getActivity().getBaseTheme().equals(Theme.LIGHT) ? "#2B2B2B" : "#FAFAFA";
String albumPhotoCountHtml = "<b><font color='" + hexAccentColor + "'>420</font></b>";
((TextView) v.findViewById(R.id.album_photos_count)).setText(StringUtils.html(albumPhotoCountHtml));
((TextView) v.findViewById(R.id.album_media_label)).setTextColor(getActivity().getTextColor());
v.findViewById(R.id.ll_n_media).setVisibility( chkShowNPhots.isChecked() ? View.VISIBLE : View.GONE);
chkShowNPhots.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
v.findViewById(R.id.ll_n_media).setVisibility(b ? View.VISIBLE : View.GONE);
}
});
((TextView) v.findViewById(R.id.album_name)).setText(StringUtils.html("<i><font color='" + textColor + "'>PraiseDuarte</font></i>"));
((CardView) v).setUseCompatPadding(true);
((CardView) v).setRadius(2);
((LinearLayout) dialogLayout.findViewById(R.id.ll_preview_album_card)).removeAllViews();
((LinearLayout) dialogLayout.findViewById(R.id.ll_preview_album_card)).addView(v);
}
});
switch (CardViewStyle.fromValue(getSP().getInt("card_view_style", 0))) {
case COMPACT: rCompact.setChecked(true); break;
case FLAT: rFlat.setChecked(true); break;
case MATERIAL: default: rMaterial.setChecked(true); break;
}
builder.setNegativeButton(getActivity().getString(R.string.cancel).toUpperCase(), null);
builder.setPositiveButton(getActivity().getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (rGroup.getCheckedRadioButtonId()) {
case R.id.radio_card_material:
default: getSP().putInt("card_view_style", CardViewStyle.MATERIAL.getValue()); break;
case R.id.radio_card_flat: getSP().putInt("card_view_style", CardViewStyle.FLAT.getValue()); break;
case R.id.radio_card_compact: getSP().putInt("card_view_style", CardViewStyle.COMPACT.getValue()); break;
}
getSP().putBoolean("show_n_photos", chkShowNPhots.isChecked());
Toast.makeText(getActivity(), getActivity().getString(R.string.card_style_alert), Toast.LENGTH_SHORT).show();
}
});
builder.setView(dialogLayout);
builder.show();
}
}
package org.horaapps.leafpic.settings;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.SettingsActivity;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.util.ColorPalette;
import org.horaapps.leafpic.util.PreferenceUtil;
import uz.shift.colorpicker.LineColorPicker;
import uz.shift.colorpicker.OnColorChangedListener;
import static org.horaapps.leafpic.util.Theme.AMOLED;
import static org.horaapps.leafpic.util.Theme.DARK;
import static org.horaapps.leafpic.util.Theme.LIGHT;
/**
* Created by dnld on 12/9/16.
*/
public class ColorsSetting extends ThemedSetting {
public ColorsSetting(ThemedActivity activity, PreferenceUtil SP) {
super(activity, SP);
}
public ColorsSetting(PreferenceUtil SP) {
super(SP);
}
public void choseBaseTheme() {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
final View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_basic_theme, null);
final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.basic_theme_title);
final CardView dialogCardView = (CardView) dialogLayout.findViewById(R.id.basic_theme_card);
/** SET OBJ THEME **/
dialogTitle.setBackgroundColor(getActivity().getPrimaryColor());
dialogCardView.setCardBackgroundColor(getActivity().getCardBackgroundColor());
dialogBuilder.setView(dialogLayout);
dialogBuilder.setView(dialogLayout);
final AlertDialog dialog = dialogBuilder.show();
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.ll_white_basic_theme:
getActivity().setBaseTheme(LIGHT);
break;
case R.id.ll_dark_basic_theme:
getActivity().setBaseTheme(DARK);
break;
case R.id.ll_dark_amoled_basic_theme:
getActivity().setBaseTheme(AMOLED);
break;
}
getActivity().updateUiElements();
dialog.dismiss();
}
};
dialogLayout.findViewById(R.id.ll_white_basic_theme).setOnClickListener(listener);
dialogLayout.findViewById(R.id.ll_dark_basic_theme).setOnClickListener(listener);
dialogLayout.findViewById(R.id.ll_dark_amoled_basic_theme).setOnClickListener(listener);
}
public void chosePrimaryColor(final SettingsActivity activity) {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
final View dialogLayout = LayoutInflater.from(activity).inflate(R.layout.color_piker_primary, null);
final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary);
final LineColorPicker colorPicker2 = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_primary_2);
final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_primary_title);
CardView dialogCardView = (CardView) dialogLayout.findViewById(R.id.cp_primary_card);
dialogCardView.setCardBackgroundColor(activity.getCardBackgroundColor());
colorPicker.setColors(ColorPalette.getBaseColors(activity));
for (int i : colorPicker.getColors())
for (int i2 : ColorPalette.getColors(activity, i))
if (i2 == activity.getPrimaryColor()) {
colorPicker.setSelectedColor(i);
colorPicker2.setColors(ColorPalette.getColors(activity, i));
colorPicker2.setSelectedColor(i2);
break;
}
dialogTitle.setBackgroundColor(activity.getPrimaryColor());
colorPicker2.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int c) {
activity.updateViewsWithPrimaryColor(c);
dialogTitle.setBackgroundColor(c);
}
});
colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int c) {
colorPicker2.setColors(ColorPalette.getColors(activity, colorPicker.getColor()));
colorPicker2.setSelectedColor(colorPicker.getColor());
}
});
dialogBuilder.setView(dialogLayout);
dialogBuilder.setNeutralButton(activity.getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
activity.updateViewsWithPrimaryColor(activity.getPrimaryColor());
dialog.cancel();
}
});
dialogBuilder.setPositiveButton(activity.getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
getSP().putInt(activity.getString(R.string.preference_primary_color), colorPicker2.getColor());
activity.updateTheme();
activity.updateViewsWithPrimaryColor(activity.getPrimaryColor());
}
});
dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
activity.updateViewsWithPrimaryColor(activity.getPrimaryColor());
}
});
dialogBuilder.show();
}
public void choseAccentColor(final SettingsActivity activity) {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
final View dialogLayout = LayoutInflater.from(activity).inflate(R.layout.color_piker_accent, null);
final LineColorPicker colorPicker = (LineColorPicker) dialogLayout.findViewById(R.id.color_picker_accent);
final TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.cp_accent_title);
CardView cv = (CardView) dialogLayout.findViewById(R.id.cp_accent_card);
cv.setCardBackgroundColor(activity.getCardBackgroundColor());
colorPicker.setColors(ColorPalette.getAccentColors(activity.getApplicationContext()));
colorPicker.setSelectedColor(activity.getAccentColor());
dialogTitle.setBackgroundColor(activity.getAccentColor());
colorPicker.setOnColorChangedListener(new OnColorChangedListener() {
@Override
public void onColorChanged(int c) {
dialogTitle.setBackgroundColor(c);
// TODO: 12/9/16 callback
activity.updateViewsWithAccentColor(colorPicker.getColor());
}
});
dialogBuilder.setView(dialogLayout);
dialogBuilder.setNeutralButton(activity.getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
activity.updateViewsWithAccentColor(activity.getAccentColor());
}
});
dialogBuilder.setPositiveButton(activity.getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
getSP().putInt(activity.getString(R.string.preference_accent_color), colorPicker.getColor());
activity.updateTheme();
activity.updateViewsWithAccentColor(activity.getAccentColor());
}
});
dialogBuilder.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
activity.updateViewsWithAccentColor(activity.getAccentColor());
}
});
dialogBuilder.show();
}
}
package org.horaapps.leafpic.settings;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.SeekBar;
import android.widget.TextView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.util.PreferenceUtil;
/**
* Created by dnld on 12/9/16.
*/
public class GeneralSetting extends ThemedSetting {
public GeneralSetting(ThemedActivity activity, PreferenceUtil SP) {
super(activity, SP);
}
public void editNumberOfColumns(){
AlertDialog.Builder multiColumnDialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_multi_column, null);
((TextView) dialogLayout.findViewById(R.id.folders_title)).setTextColor(getActivity().getTextColor());
((TextView) dialogLayout.findViewById(R.id.media_title)).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);
nColFolders.setTextColor(getActivity().getSubTextColor());
nColMedia.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);
getActivity().themeSeekBar(barFolders);
getActivity().themeSeekBar(barMedia);
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);
barFolders.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
nColFolders.setText(String.valueOf(i+1));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
barMedia.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
nColMedia.setText(String.valueOf(i+1));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
multiColumnDialogBuilder.setPositiveButton(getActivity().getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int nFolders = Integer.parseInt(nColFolders.getText().toString());
int nMedia = Integer.parseInt(nColMedia.getText().toString());
getSP().putInt("n_columns_folders", nFolders);
getSP().putInt("n_columns_media", nMedia);
}
});
multiColumnDialogBuilder.setNegativeButton(getActivity().getString(R.string.cancel).toUpperCase(), null);
multiColumnDialogBuilder.setView(dialogLayout);
multiColumnDialogBuilder.show();
}
}
package org.horaapps.leafpic.settings;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.base.ThemedActivity;
import org.horaapps.leafpic.util.PreferenceUtil;
import org.horaapps.leafpic.util.StaticMapProvider;
/**
* Created by dnld on 12/9/16.
*/
public class MapProviderSetting extends ThemedSetting {
public MapProviderSetting(ThemedActivity activity, PreferenceUtil SP) {
super(activity, SP);
}
public void choseProvider() {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_map_provider, null);
TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.title);
((CardView) dialogLayout.findViewById(R.id.dialog_chose_provider_title)).setCardBackgroundColor(getActivity().getCardBackgroundColor());
dialogTitle.setBackgroundColor(getActivity().getPrimaryColor());
final RadioGroup mapProvider = (RadioGroup) dialogLayout.findViewById(R.id.radio_group_maps_provider);
RadioButton radioGoogleMaps = (RadioButton) dialogLayout.findViewById(R.id.radio_google_maps);
RadioButton radioMapBoxStreets = (RadioButton) dialogLayout.findViewById(R.id.radio_mapb_streets);
RadioButton radioMapBoxDark = (RadioButton) dialogLayout.findViewById(R.id.radio_mapb_dark);
RadioButton radioMapBoxLight = (RadioButton) dialogLayout.findViewById(R.id.radio_mapb_light);
RadioButton radioTyler = (RadioButton) dialogLayout.findViewById(R.id.radio_osm_tyler);
getActivity().themeRadioButton(radioGoogleMaps);
getActivity().themeRadioButton(radioMapBoxStreets);
getActivity().themeRadioButton(radioMapBoxDark);