Skip to content

Internationalization of date & time formats, add German translation #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.developer.filepicker.R;
import com.developer.filepicker.controller.NotifyItemChecked;
import com.developer.filepicker.model.DialogConfigs;
Expand All @@ -18,15 +19,15 @@
import com.developer.filepicker.model.MarkedItemList;
import com.developer.filepicker.widget.MaterialCheckbox;
import com.developer.filepicker.widget.OnCheckedChangeListener;
import java.text.SimpleDateFormat;

import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;

/**
* @author akshay sunil masram
*/
public class FileListAdapter extends BaseAdapter{
public class FileListAdapter extends BaseAdapter {
private ArrayList<FileListItem> listItem;
private Context context;
private DialogProperties properties;
Expand Down Expand Up @@ -60,85 +61,74 @@ public View getView(final int i, View view, ViewGroup viewGroup) {
view = LayoutInflater.from(context).inflate(R.layout.dialog_file_list_item, viewGroup, false);
holder = new ViewHolder(view);
view.setTag(holder);
}
else
{ holder = (ViewHolder)view.getTag();
} else {
holder = (ViewHolder) view.getTag();
}
final FileListItem item = listItem.get(i);
if (MarkedItemList.hasItem(item.getLocation())) {
Animation animation = AnimationUtils.loadAnimation(context,R.anim.marked_item_animation);
Animation animation = AnimationUtils.loadAnimation(context, R.anim.marked_item_animation);
view.setAnimation(animation);
}
else {
Animation animation = AnimationUtils.loadAnimation(context,R.anim.unmarked_item_animation);
} else {
Animation animation = AnimationUtils.loadAnimation(context, R.anim.unmarked_item_animation);
view.setAnimation(animation);
}
if (item.isDirectory()) {
holder.type_icon.setImageResource(R.mipmap.ic_type_folder);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
holder.type_icon.setColorFilter(context.getResources().getColor(R.color.colorPrimary,context.getTheme()));
holder.type_icon.setColorFilter(context.getResources().getColor(R.color.colorPrimary, context.getTheme()));
} else {
holder.type_icon.setColorFilter(context.getResources().getColor(R.color.colorPrimary));
}
else
{ holder.type_icon.setColorFilter(context.getResources().getColor(R.color.colorPrimary));
if (properties.selection_type == DialogConfigs.FILE_SELECT) {
holder.fmark.setVisibility(View.INVISIBLE);
} else {
holder.fmark.setVisibility(View.VISIBLE);
}
if(properties.selection_type == DialogConfigs.FILE_SELECT)
{ holder.fmark.setVisibility(View.INVISIBLE);
}
else
{ holder.fmark.setVisibility(View.VISIBLE);
}
}
else {
} else {
holder.type_icon.setImageResource(R.mipmap.ic_type_file);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
holder.type_icon.setColorFilter(context.getResources().getColor(R.color.colorAccent,context.getTheme()));
holder.type_icon.setColorFilter(context.getResources().getColor(R.color.colorAccent, context.getTheme()));
} else {
holder.type_icon.setColorFilter(context.getResources().getColor(R.color.colorAccent));
}
else
{ holder.type_icon.setColorFilter(context.getResources().getColor(R.color.colorAccent));
}
if(properties.selection_type == DialogConfigs.DIR_SELECT)
{ holder.fmark.setVisibility(View.INVISIBLE);
}
else
{ holder.fmark.setVisibility(View.VISIBLE);
if (properties.selection_type == DialogConfigs.DIR_SELECT) {
holder.fmark.setVisibility(View.INVISIBLE);
} else {
holder.fmark.setVisibility(View.VISIBLE);
}
}
holder.type_icon.setContentDescription(item.getFilename());
holder.name.setText(item.getFilename());
SimpleDateFormat sdate = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
SimpleDateFormat stime = new SimpleDateFormat("hh:mm aa", Locale.getDefault());
DateFormat dateFormatter = android.text.format.DateFormat.getMediumDateFormat(context);
DateFormat timeFormatter = android.text.format.DateFormat.getTimeFormat(context);
Date date = new Date(item.getTime());
if(i==0&&item.getFilename().startsWith(context.getString(R.string.label_parent_dir))) {
if (i == 0 && item.getFilename().startsWith(context.getString(R.string.label_parent_dir))) {
holder.type.setText(R.string.label_parent_directory);
} else {
holder.type.setText(String.format(context.getString(R.string.last_edit), dateFormatter.format(date), timeFormatter.format(date)));
}
else {
holder.type.setText(context.getString(R.string.last_edit) + sdate.format(date) + ", " + stime.format(date));
}
if(holder.fmark.getVisibility()==View.VISIBLE) {
if(i==0&&item.getFilename().startsWith(context.getString(R.string.label_parent_dir)))
{ holder.fmark.setVisibility(View.INVISIBLE);
if (holder.fmark.getVisibility() == View.VISIBLE) {
if (i == 0 && item.getFilename().startsWith(context.getString(R.string.label_parent_dir))) {
holder.fmark.setVisibility(View.INVISIBLE);
}
if (MarkedItemList.hasItem(item.getLocation())) {
holder.fmark.setChecked(true);
}
else {
} else {
holder.fmark.setChecked(false);
}
}

holder.fmark.setOnCheckedChangedListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(MaterialCheckbox checkbox, boolean isChecked) {
item.setMarked(isChecked);
if (item.isMarked()) {
if(properties.selection_mode == DialogConfigs.MULTI_MODE) {
if (properties.selection_mode == DialogConfigs.MULTI_MODE) {
MarkedItemList.addSelectedItem(item);
}
else {
} else {
MarkedItemList.addSingleFile(item);
}
}
else {
} else {
MarkedItemList.removeSelectedItem(item.getLocation());
}
notifyItemChecked.notifyCheckBoxIsClicked();
Expand All @@ -147,16 +137,16 @@ public void onCheckedChanged(MaterialCheckbox checkbox, boolean isChecked) {
return view;
}

private class ViewHolder
{ ImageView type_icon;
TextView name,type;
private class ViewHolder {
ImageView type_icon;
TextView name, type;
MaterialCheckbox fmark;

ViewHolder(View itemView) {
name= itemView.findViewById(R.id.fname);
type= itemView.findViewById(R.id.ftype);
type_icon= itemView.findViewById(R.id.image_type);
fmark= itemView.findViewById(R.id.file_mark);
name = itemView.findViewById(R.id.fname);
type = itemView.findViewById(R.id.ftype);
type_icon = itemView.findViewById(R.id.image_type);
fmark = itemView.findViewById(R.id.file_mark);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ public void notifyCheckBoxIsClicked() {
int color;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
color = context.getResources().getColor(R.color.colorAccent, context.getTheme());
}
else {
} else {
color = context.getResources().getColor(R.color.colorAccent);
}
select.setTextColor(Color.argb(128, Color.red(color), Color.green(color), Color.blue(color)));
Expand All @@ -139,8 +138,7 @@ public void notifyCheckBoxIsClicked() {
int color;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
color = context.getResources().getColor(R.color.colorAccent, context.getTheme());
}
else {
} else {
color = context.getResources().getColor(R.color.colorAccent);
}
select.setTextColor(color);
Expand Down Expand Up @@ -188,8 +186,8 @@ protected void onStart() {
super.onStart();
positiveBtnNameStr = (
positiveBtnNameStr == null ?
context.getResources().getString(R.string.choose_button_label) :
positiveBtnNameStr
context.getResources().getString(R.string.choose_button_label) :
positiveBtnNameStr
);
select.setText(positiveBtnNameStr);
if (Utility.checkStorageAccessPermissions(context)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class FilePickerPreference extends Preference implements DialogSelectionL

private FilePickerDialog mDialog;
private DialogProperties properties;
private String titleText=null;
private String titleText = null;

public FilePickerPreference(Context context) {
super(context);
Expand Down Expand Up @@ -96,18 +96,17 @@ private void showDialog(Bundle state) {

@Override
public void onSelectedFilePaths(String[] files) {
StringBuilder buff=new StringBuilder();
for(String path:files)
{ buff.append(path).append(":");
StringBuilder buff = new StringBuilder();
for (String path : files) {
buff.append(path).append(":");
}
String dFiles = buff.toString();
if (isPersistent()) {
persistString(dFiles);
}
try {
getOnPreferenceChangeListener().onPreferenceChange(this, dFiles);
}
catch (NullPointerException e) {
} catch (NullPointerException e) {
e.printStackTrace();
}
}
Expand All @@ -118,8 +117,8 @@ public boolean onPreferenceClick(Preference preference) {
return false;
}

public void setProperties(DialogProperties properties)
{ mDialog.setProperties(properties);
public void setProperties(DialogProperties properties) {
mDialog.setProperties(properties);
}

private static class SavedState extends BaseSavedState {
Expand All @@ -141,56 +140,49 @@ public SavedState(Parcelable superState) {
}

public static final Creator<SavedState> CREATOR =
new Creator<SavedState>() {
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}

public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
new Creator<SavedState>() {
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}

public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
}

private void initProperties(AttributeSet attrs) {
TypedArray tarr=getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.FilePickerPreference,0,0);
TypedArray tarr = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.FilePickerPreference, 0, 0);
final int N = tarr.getIndexCount();
for (int i = 0; i < N; ++i)
{ int attr = tarr.getIndex(i);
for (int i = 0; i < N; ++i) {
int attr = tarr.getIndex(i);
if (attr == R.styleable.FilePickerPreference_selection_mode) {
properties.selection_mode=tarr.getInteger(R.styleable.FilePickerPreference_selection_mode, DialogConfigs.SINGLE_MODE);
}
else if (attr == R.styleable.FilePickerPreference_selection_type) {
properties.selection_type=tarr.getInteger(R.styleable.FilePickerPreference_selection_type,DialogConfigs.FILE_SELECT);
}
else if (attr == R.styleable.FilePickerPreference_root_dir) {
String root_dir=tarr.getString(R.styleable.FilePickerPreference_root_dir);
if(root_dir!=null&&!root_dir.equals(""))
{ properties.root=new File(root_dir);
properties.selection_mode = tarr.getInteger(R.styleable.FilePickerPreference_selection_mode, DialogConfigs.SINGLE_MODE);
} else if (attr == R.styleable.FilePickerPreference_selection_type) {
properties.selection_type = tarr.getInteger(R.styleable.FilePickerPreference_selection_type, DialogConfigs.FILE_SELECT);
} else if (attr == R.styleable.FilePickerPreference_root_dir) {
String root_dir = tarr.getString(R.styleable.FilePickerPreference_root_dir);
if (root_dir != null && !root_dir.equals("")) {
properties.root = new File(root_dir);
}
}
else if (attr == R.styleable.FilePickerPreference_error_dir) {
String error_dir=tarr.getString(R.styleable.FilePickerPreference_error_dir);
if(error_dir!=null&&!error_dir.equals(""))
{ properties.error_dir=new File(error_dir);
} else if (attr == R.styleable.FilePickerPreference_error_dir) {
String error_dir = tarr.getString(R.styleable.FilePickerPreference_error_dir);
if (error_dir != null && !error_dir.equals("")) {
properties.error_dir = new File(error_dir);
}
}
else if (attr == R.styleable.FilePickerPreference_offset_dir) {
String offset_dir=tarr.getString(R.styleable.FilePickerPreference_offset_dir);
if(offset_dir!=null&&!offset_dir.equals(""))
{ properties.offset=new File(offset_dir);
} else if (attr == R.styleable.FilePickerPreference_offset_dir) {
String offset_dir = tarr.getString(R.styleable.FilePickerPreference_offset_dir);
if (offset_dir != null && !offset_dir.equals("")) {
properties.offset = new File(offset_dir);
}
}
else if (attr == R.styleable.FilePickerPreference_extensions) {
String extensions=tarr.getString(R.styleable.FilePickerPreference_extensions);
if(extensions!=null&&!extensions.equals(""))
{ properties.extensions= extensions.split(":");
} else if (attr == R.styleable.FilePickerPreference_extensions) {
String extensions = tarr.getString(R.styleable.FilePickerPreference_extensions);
if (extensions != null && !extensions.equals("")) {
properties.extensions = extensions.split(":");
}
}
else if (attr == R.styleable.FilePickerPreference_title_text) {
titleText=tarr.getString(R.styleable.FilePickerPreference_title_text);
}
else if (attr == R.styleable.FilePickerPreference_show_hidden_files) {
} else if (attr == R.styleable.FilePickerPreference_title_text) {
titleText = tarr.getString(R.styleable.FilePickerPreference_title_text);
} else if (attr == R.styleable.FilePickerPreference_show_hidden_files) {
properties.show_hidden_files = tarr.getBoolean(R.styleable.FilePickerPreference_show_hidden_files, false);
}
}
Expand Down
Loading