Merged in icon_text_size (pull request #56)

Icon text size
This commit is contained in:
tom79 2017-08-15 15:10:58 +00:00
commit 4a5e8bf38f
20 changed files with 187 additions and 11 deletions

View File

@ -46,6 +46,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
@ -552,6 +553,67 @@ public class MainActivity extends AppCompatActivity
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}else if( id == R.id.action_size){
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int textSize = sharedpreferences.getInt(Helper.SET_TEXT_SIZE,100);
int iconSize = sharedpreferences.getInt(Helper.SET_ICON_SIZE,100);
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle(R.string.text_size);
View popup_quick_settings = getLayoutInflater().inflate( R.layout.popup_text_size, null );
builder.setView(popup_quick_settings);
SeekBar set_text_size = (SeekBar) popup_quick_settings.findViewById(R.id.set_text_size);
SeekBar set_icon_size = (SeekBar) popup_quick_settings.findViewById(R.id.set_icon_size);
final TextView set_text_size_value = (TextView) popup_quick_settings.findViewById(R.id.set_text_size_value);
final TextView set_icon_size_value = (TextView) popup_quick_settings.findViewById(R.id.set_icon_size_value);
set_text_size_value.setText(String.format("%s%%",String.valueOf(textSize)));
set_icon_size_value.setText(String.format("%s%%",String.valueOf(iconSize)));
set_text_size.setMax(20);
set_icon_size.setMax(20);
set_text_size.setProgress(((textSize-50)/5));
set_icon_size.setProgress(((iconSize-50)/5));
set_text_size.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int value = 50 + progress*5;
set_text_size_value.setText(String.format("%s%%",String.valueOf(value)));
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putInt(Helper.SET_TEXT_SIZE, value);
editor.apply();
}
});
set_icon_size.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int value = 50 + progress*5;
set_icon_size_value.setText(String.format("%s%%",String.valueOf(value)));
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putInt(Helper.SET_ICON_SIZE, value);
editor.apply();
}
});
builder.setPositiveButton(R.string.validate, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
MainActivity.this.recreate();
dialog.dismiss();
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
return super.onOptionsItemSelected(item);

View File

@ -28,6 +28,7 @@ import android.support.v7.widget.CardView;
import android.text.Html;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -152,6 +153,13 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
} else {
holder = (ViewHolder) convertView.getTag();
}
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int iconSizePercent = sharedpreferences.getInt(Helper.SET_ICON_SIZE, 100);
int textSizePercent = sharedpreferences.getInt(Helper.SET_TEXT_SIZE, 100);
final float scale = context.getResources().getDisplayMetrics().density;
String type = notification.getType();
String typeString = "";
@ -182,8 +190,16 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
break;
}
holder.notification_type.setText(typeString);
holder.status_privacy.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_privacy.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_reply.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_reply.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.notification_status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.notification_type.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.notification_account_username.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.status_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12*textSizePercent/100);
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
//Manages theme for icon colors
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
@ -223,11 +239,11 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
holder.status_document_container.setVisibility(View.VISIBLE);
if( (status.getIn_reply_to_account_id() != null && !status.getIn_reply_to_account_id().equals("null")) || (status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().equals("null")) ){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply);
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
img.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (15 * iconSizePercent/100 * scale + 0.5f));
holder.notification_account_username.setCompoundDrawables( img, null, null, null);
}else if( status.isReblogged()){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_retweet);
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
img.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (15 * iconSizePercent/100 * scale + 0.5f));
holder.notification_account_username.setCompoundDrawables( img, null, null, null);
}else{
holder.notification_account_username.setCompoundDrawables( null, null, null, null);
@ -302,8 +318,8 @@ public class NotificationsListAdapter extends BaseAdapter implements OnPostActio
else
imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_retweet_black);
imgFav.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (20 * scale + 0.5f));
imgReblog.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (20 * scale + 0.5f));
imgFav.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
imgReblog.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
holder.status_favorite_count.setCompoundDrawables(imgFav, null, null, null);
holder.status_reblog_count.setCompoundDrawables(imgReblog, null, null, null);

View File

@ -34,6 +34,7 @@ import android.text.Selection;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.util.TypedValue;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@ -200,6 +201,29 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
} else {
holder = (ViewHolder) convertView.getTag();
}
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int iconSizePercent = sharedpreferences.getInt(Helper.SET_ICON_SIZE, 100);
int textSizePercent = sharedpreferences.getInt(Helper.SET_TEXT_SIZE, 100);
holder.status_more.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_more.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_privacy.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_privacy.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_reply.getLayoutParams().height = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_reply.getLayoutParams().width = (int) Helper.convertDpToPixel((20*iconSizePercent/100), context);
holder.status_content.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.status_account_displayname.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.status_account_username.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12*textSizePercent/100);
holder.status_reblog_user.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.status_toot_date.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12*textSizePercent/100);
holder.status_spoiler.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
holder.status_content_translated.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14*textSizePercent/100);
if( status.getSpoiler_text() != null && status.getSpoiler_text().trim().length() > 0 && !status.isSpoilerShown()){
holder.status_content_container.setVisibility(View.GONE);
holder.status_spoiler_container.setVisibility(View.VISIBLE);
@ -267,7 +291,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
holder.status_action_container.setVisibility(View.GONE);
}
//Manages theme for icon colors
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if( theme == Helper.THEME_DARK){
changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_text);
@ -301,11 +324,11 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
final float scale = context.getResources().getDisplayMetrics().density;
if( !status.getIn_reply_to_account_id().equals("null") || !status.getIn_reply_to_id().equals("null") ){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply);
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
img.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (15 * iconSizePercent/100 * scale + 0.5f));
holder.status_account_displayname.setCompoundDrawables( img, null, null, null);
}else if( status.getReblog() != null){
Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_retweet_black);
img.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (15 * scale + 0.5f));
img.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (15 * iconSizePercent/100 * scale + 0.5f));
holder.status_account_displayname.setCompoundDrawables( img, null, null, null);
}else{
holder.status_account_displayname.setCompoundDrawables( null, null, null, null);
@ -539,8 +562,8 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
else
imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_retweet_black);
imgFav.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (20 * scale + 0.5f));
imgReblog.setBounds(0,0,(int) (20 * scale + 0.5f),(int) (20 * scale + 0.5f));
imgFav.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
imgReblog.setBounds(0,0,(int) (20 * iconSizePercent/100 * scale + 0.5f),(int) (20 * iconSizePercent/100 * scale + 0.5f));
holder.status_favorite_count.setCompoundDrawables(imgFav, null, null, null);
holder.status_reblog_count.setCompoundDrawables(imgReblog, null, null, null);
@ -1079,4 +1102,5 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf
builderSingle.create().requestWindowFeature(Window.FEATURE_NO_TITLE);
builderSingle.show();
}
}

View File

@ -194,6 +194,8 @@ public class Helper {
public static final String SET_NSFW_TIMEOUT = "set_nsfw_timeout";
public static final String SET_TABS = "set_tabs";
public static final String SET_MEDIA_URLS = "set_media_urls";
public static final String SET_TEXT_SIZE = "set_text_size";
public static final String SET_ICON_SIZE = "set_icon_size";
public static final int ATTACHMENT_ALWAYS = 1;
public static final int ATTACHMENT_WIFI = 2;
public static final int ATTACHMENT_ASK = 3;

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="@dimen/drawer_padding"
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content">
<TextView
android:layout_marginTop="20dp"
android:layout_gravity="center"
android:text="@string/text_size_change"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content">
<TextView
android:id="@+id/set_text_size_value"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_width="50dp"
android:layout_height="wrap_content" />
<SeekBar
android:layout_gravity="center_vertical"
android:id="@+id/set_text_size"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</SeekBar>
</LinearLayout>
<TextView
android:layout_marginTop="20dp"
android:layout_gravity="center"
android:text="@string/icon_size_change"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content">
<TextView
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:id="@+id/set_icon_size_value"
android:layout_gravity="center"
android:layout_width="50dp"
android:layout_height="wrap_content" />
<SeekBar
android:layout_gravity="center_vertical"
android:id="@+id/set_icon_size"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</SeekBar>
</LinearLayout>
</LinearLayout>

View File

@ -13,6 +13,10 @@
android:id="@+id/action_about_instance"
android:title="@string/action_about_instance"
app:showAsAction="never" />
<item
android:id="@+id/action_size"
android:title="@string/text_size"
app:showAsAction="never" />
<item
android:id="@+id/action_cache"
android:title="@string/action_cache"

View File

@ -45,6 +45,9 @@
<string name="speech_not_supported">Désolé ! Votre appareil ne supporte pas la commande vocale !</string>
<string name="delete_all">Tout effacer</string>
<string name="schedule">Programmer</string>
<string name="text_size">Taille du texte et des icônes</string>
<string name="text_size_change">Modifier la taille du texte :</string>
<string name="icon_size_change">Modifier la taille des icônes :</string>
<string name="next">Suivant</string>
<string name="previous">Précédent</string>
<string name="open_with">Ouvrir avec</string>

View File

@ -47,7 +47,9 @@
<string name="delete_all">Delete all</string>
<string name="schedule">Schedule</string>
<string name="text_size">Text and icon sizes</string>
<string name="text_size_change">Change the current text size:</string>
<string name="icon_size_change">Change the current icon size:</string>
<string name="next">Next</string>
<string name="previous">Previous</string>
<string name="open_with">Open with</string>