added option to set image quality, layout fix

This commit is contained in:
nuclearfog 2020-10-28 16:15:02 +01:00
parent 2cbd2f1858
commit bc274c9d4a
No known key found for this signature in database
GPG Key ID: D5490E4A81F97B14
12 changed files with 116 additions and 30 deletions

View File

@ -75,7 +75,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
private Button colorButton1, colorButton2, colorButton3, colorButton4; private Button colorButton1, colorButton2, colorButton3, colorButton4;
private EditText proxyAddr, proxyPort, proxyUser, proxyPass; private EditText proxyAddr, proxyPort, proxyUser, proxyPass;
private NumberPicker load_picker; private NumberPicker load_picker;
private CompoundButton enableProxy, enableAuth; private CompoundButton enableProxy, enableAuth, hqImage;
private Spinner locationSpinner; private Spinner locationSpinner;
private LocationAdapter locationAdapter; private LocationAdapter locationAdapter;
private View root, colorButton1_edge; private View root, colorButton1_edge;
@ -97,6 +97,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
Spinner fontSpinner = findViewById(R.id.spinner_font); Spinner fontSpinner = findViewById(R.id.spinner_font);
enableProxy = findViewById(R.id.settings_enable_proxy); enableProxy = findViewById(R.id.settings_enable_proxy);
enableAuth = findViewById(R.id.settings_enable_auth); enableAuth = findViewById(R.id.settings_enable_auth);
hqImage = findViewById(R.id.settings_image_hq);
locationSpinner = findViewById(R.id.spinner_woeid); locationSpinner = findViewById(R.id.spinner_woeid);
colorButton1_edge = findViewById(R.id.color_background_edge); colorButton1_edge = findViewById(R.id.color_background_edge);
colorButton1 = findViewById(R.id.color_background); colorButton1 = findViewById(R.id.color_background);
@ -151,6 +152,8 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
load_picker.setValue((settings.getListSize()) / 10); load_picker.setValue((settings.getListSize()) / 10);
enableProxy.setChecked(settings.isProxyEnabled()); enableProxy.setChecked(settings.isProxyEnabled());
enableAuth.setChecked(settings.isProxyAuthSet()); enableAuth.setChecked(settings.isProxyAuthSet());
hqImage.setEnabled(settings.getImageLoad());
hqImage.setChecked(settings.getImageQuality());
setProxySetupVisibility(settings.isProxyEnabled(), settings.isProxyAuthSet()); setProxySetupVisibility(settings.isProxyEnabled(), settings.isProxyAuthSet());
proxyDialog = DialogBuilder.create(this, WRONG_PROXY, this); proxyDialog = DialogBuilder.create(this, WRONG_PROXY, this);
@ -168,6 +171,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
toggleAns.setOnCheckedChangeListener(this); toggleAns.setOnCheckedChangeListener(this);
enableProxy.setOnCheckedChangeListener(this); enableProxy.setOnCheckedChangeListener(this);
enableAuth.setOnCheckedChangeListener(this); enableAuth.setOnCheckedChangeListener(this);
hqImage.setOnCheckedChangeListener(this);
fontSpinner.setOnItemSelectedListener(this); fontSpinner.setOnItemSelectedListener(this);
locationSpinner.setOnItemSelectedListener(this); locationSpinner.setOnItemSelectedListener(this);
load_dialog_selector.setOnDismissListener(this); load_dialog_selector.setOnDismissListener(this);
@ -344,6 +348,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
switch (c.getId()) { switch (c.getId()) {
case R.id.toggleImg: case R.id.toggleImg:
settings.setImageLoad(checked); settings.setImageLoad(checked);
hqImage.setEnabled(checked);
break; break;
case R.id.toggleAns: case R.id.toggleAns:
@ -357,6 +362,10 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
case R.id.settings_enable_auth: case R.id.settings_enable_auth:
setProxySetupVisibility(true, checked); setProxySetupVisibility(true, checked);
break; break;
case R.id.settings_image_hq:
settings.setHighQualityImage(checked);
break;
} }
} }

View File

@ -432,7 +432,7 @@ public class TweetActivity extends AppCompatActivity implements OnClickListener,
if (settings.getImageLoad()) { if (settings.getImageLoad()) {
String pbLink = tweet.getUser().getImageLink(); String pbLink = tweet.getUser().getImageLink();
if (!tweet.getUser().hasDefaultProfileImage()) if (!tweet.getUser().hasDefaultProfileImage())
pbLink += "_bigger"; pbLink += settings.getImageSuffix();
Picasso.get().load(pbLink).error(R.drawable.no_image).into(profile_img); Picasso.get().load(pbLink).error(R.drawable.no_image).into(profile_img);
} }
String placeName = tweet.getLocationName(); String placeName = tweet.getLocationName();

View File

@ -220,7 +220,7 @@ public class ListAdapter extends Adapter<ViewHolder> {
if (settings.getImageLoad()) { if (settings.getImageLoad()) {
String pbLink = owner.getImageLink(); String pbLink = owner.getImageLink();
if (!owner.hasDefaultProfileImage()) { if (!owner.hasDefaultProfileImage()) {
pbLink += "_mini"; pbLink += settings.getImageSuffix();
} }
Picasso.get().load(pbLink).error(R.drawable.no_image).into(vh.pb_image); Picasso.get().load(pbLink).error(R.drawable.no_image).into(vh.pb_image);
} }

View File

@ -153,7 +153,7 @@ public class MessageAdapter extends Adapter<ViewHolder> {
if (settings.getImageLoad()) { if (settings.getImageLoad()) {
String pbLink = sender.getImageLink(); String pbLink = sender.getImageLink();
if (!sender.hasDefaultProfileImage()) { if (!sender.hasDefaultProfileImage()) {
pbLink += "_mini"; pbLink += settings.getImageSuffix();
} }
Picasso.get().load(pbLink).error(R.drawable.no_image).into(holder.profile_img); Picasso.get().load(pbLink).error(R.drawable.no_image).into(holder.profile_img);
} }

View File

@ -248,7 +248,7 @@ public class TweetAdapter extends Adapter<ViewHolder> {
if (settings.getImageLoad()) { if (settings.getImageLoad()) {
String pbLink = user.getImageLink(); String pbLink = user.getImageLink();
if (!user.hasDefaultProfileImage()) if (!user.hasDefaultProfileImage())
pbLink += "_mini"; pbLink += settings.getImageSuffix();
Picasso.get().load(pbLink).error(R.drawable.no_image).into(vh.profile); Picasso.get().load(pbLink).error(R.drawable.no_image).into(vh.profile);
} else { } else {
vh.profile.setImageResource(0); vh.profile.setImageResource(0);

View File

@ -192,7 +192,7 @@ public class UserAdapter extends Adapter<ViewHolder> {
if (settings.getImageLoad()) { if (settings.getImageLoad()) {
String pbLink = user.getImageLink(); String pbLink = user.getImageLink();
if (!user.hasDefaultProfileImage()) { if (!user.hasDefaultProfileImage()) {
pbLink += "_mini"; pbLink += settings.getImageSuffix();
} }
Picasso.get().load(pbLink).error(R.drawable.no_image).into(vh.profileImg); Picasso.get().load(pbLink).error(R.drawable.no_image).into(vh.profileImg);
} }

View File

@ -30,6 +30,7 @@ public class GlobalSettings {
private static final String INDEX_FONT = "index_font"; private static final String INDEX_FONT = "index_font";
private static final String LIST_SIZE = "preload"; private static final String LIST_SIZE = "preload";
private static final String IMAGE_LOAD = "image_load"; private static final String IMAGE_LOAD = "image_load";
private static final String IMAGE_QUALITY = "image_hq";
private static final String ANSWER_LOAD = "answer_load"; private static final String ANSWER_LOAD = "answer_load";
private static final String LOGGED_IN = "login"; private static final String LOGGED_IN = "login";
private static final String AUTH_KEY1 = "key1"; private static final String AUTH_KEY1 = "key1";
@ -64,6 +65,7 @@ public class GlobalSettings {
private TrendLocation location; private TrendLocation location;
private String key1, key2; private String key1, key2;
private boolean loadImage; private boolean loadImage;
private boolean hqImages;
private boolean loadAnswer; private boolean loadAnswer;
private boolean loggedIn; private boolean loggedIn;
private boolean isProxyEnabled; private boolean isProxyEnabled;
@ -196,13 +198,45 @@ public class GlobalSettings {
/** /**
* enable/disable image load load * enable/disable image load load
* *
* @param image true if enabled * @param enable true if enabled
*/ */
public void setImageLoad(boolean image) { public void setImageLoad(boolean enable) {
loadImage = image; loadImage = enable;
Editor edit = settings.edit(); Editor edit = settings.edit();
edit.putBoolean(IMAGE_LOAD, image); edit.putBoolean(IMAGE_LOAD, enable);
edit.apply();
}
/**
* sets image quality
*
* @return true if thumbnails should be in high resolution
*/
public boolean getImageQuality() {
return hqImages;
}
/**
* returns the twitter image suffix depending on the resolution
*
* @return suffix string
*/
public String getImageSuffix() {
if (hqImages)
return "_bigger";
return "_mini";
}
/**
* sets the image quality
*
* @param enable true if small thumbnails should be in high resolution
*/
public void setHighQualityImage(boolean enable) {
hqImages = enable;
Editor edit = settings.edit();
edit.putBoolean(IMAGE_QUALITY, enable);
edit.apply(); edit.apply();
} }
@ -518,6 +552,7 @@ public class GlobalSettings {
listSize = settings.getInt(LIST_SIZE, DEFAULT_LIST_SIZE); listSize = settings.getInt(LIST_SIZE, DEFAULT_LIST_SIZE);
loadImage = settings.getBoolean(IMAGE_LOAD, DEFAULT_DATA_USAGE); loadImage = settings.getBoolean(IMAGE_LOAD, DEFAULT_DATA_USAGE);
loadAnswer = settings.getBoolean(ANSWER_LOAD, DEFAULT_DATA_USAGE); loadAnswer = settings.getBoolean(ANSWER_LOAD, DEFAULT_DATA_USAGE);
hqImages = settings.getBoolean(IMAGE_QUALITY, DEFAULT_DATA_USAGE);
loggedIn = settings.getBoolean(LOGGED_IN, false); loggedIn = settings.getBoolean(LOGGED_IN, false);
key1 = settings.getString(AUTH_KEY1, ""); key1 = settings.getString(AUTH_KEY1, "");
key2 = settings.getString(AUTH_KEY2, ""); key2 = settings.getString(AUTH_KEY2, "");

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/white"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
@ -17,8 +19,8 @@
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:srcCompat="@drawable/twitter4j_badge" android:contentDescription="@string/badge_twitter4j"
android:contentDescription="@string/badge_twitter4j" /> app:srcCompat="@drawable/twitter4j_badge" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -160,39 +160,77 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"> android:orientation="horizontal"
android:paddingLeft="@dimen/settings_layout_padding"
android:paddingRight="@dimen/settings_layout_padding">
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggleImg" android:id="@+id/toggleImg"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="@dimen/settings_checkbox_height" android:layout_height="@dimen/settings_checkbox_height"
android:singleLine="true"
android:textSize="@dimen/settings_textsize_small" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/settings_checkbox_margin"
android:layout_marginLeft="@dimen/settings_checkbox_margin" android:layout_marginLeft="@dimen/settings_checkbox_margin"
android:layout_marginEnd="@dimen/settings_checkbox_margin"
android:layout_marginRight="@dimen/settings_checkbox_margin" android:layout_marginRight="@dimen/settings_checkbox_margin"
android:layout_weight="1" android:layout_weight="1"
android:singleLine="true" android:singleLine="true"
android:text="@string/settings_image" android:text="@string/settings_image"
android:textSize="@dimen/settings_textsize_small" /> android:textSize="@dimen/settings_checkbox_textsize" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggleAns" android:id="@+id/settings_image_hq"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="@dimen/settings_checkbox_height" android:layout_height="@dimen/settings_checkbox_height"
android:singleLine="true"
android:textSize="@dimen/settings_textsize_small" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/settings_checkbox_margin"
android:layout_marginLeft="@dimen/settings_checkbox_margin" android:layout_marginLeft="@dimen/settings_checkbox_margin"
android:layout_marginEnd="@dimen/settings_checkbox_margin"
android:layout_marginRight="@dimen/settings_checkbox_margin" android:layout_marginRight="@dimen/settings_checkbox_margin"
android:layout_weight="1" android:layout_weight="1"
android:singleLine="true" android:singleLine="true"
android:text="@string/load_answer" android:text="@string/settings_enable_hq_img"
android:textSize="@dimen/settings_textsize_small" /> android:textSize="@dimen/settings_checkbox_textsize" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingLeft="@dimen/settings_layout_padding" android:paddingLeft="@dimen/settings_layout_padding"
android:paddingRight="@dimen/settings_layout_padding"> android:paddingRight="@dimen/settings_layout_padding">
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggleAns"
android:layout_width="wrap_content"
android:layout_height="@dimen/settings_checkbox_height"
android:singleLine="true"
android:textSize="@dimen/settings_textsize_small" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/settings_checkbox_margin"
android:layout_marginLeft="@dimen/settings_checkbox_margin"
android:layout_marginEnd="@dimen/settings_checkbox_margin"
android:layout_marginRight="@dimen/settings_checkbox_margin"
android:layout_weight="2"
android:singleLine="true"
android:text="@string/settings_enable_ans_load"
android:textSize="@dimen/settings_checkbox_textsize" />
<Button <Button
android:id="@+id/load_dialog" android:id="@+id/load_dialog"
style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless"
@ -200,16 +238,13 @@
android:layout_height="@dimen/settings_button_height" android:layout_height="@dimen/settings_button_height"
android:layout_margin="@dimen/settings_button_margin" android:layout_margin="@dimen/settings_button_margin"
android:layout_marginStart="@dimen/settings_button_margin" android:layout_marginStart="@dimen/settings_button_margin"
android:layout_marginEnd="@dimen/settings_button_margin" android:layout_weight="3"
android:layout_weight="1"
android:background="@drawable/button" android:background="@drawable/button"
android:paddingLeft="@dimen/settings_checkbox_margin"
android:paddingRight="@dimen/settings_checkbox_margin"
android:singleLine="true" android:singleLine="true"
android:text="@string/settings_list_size" /> android:text="@string/settings_list_size" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout> </LinearLayout>
<View <View
@ -314,7 +349,8 @@
android:layout_marginLeft="@dimen/settings_checkbox_margin" android:layout_marginLeft="@dimen/settings_checkbox_margin"
android:layout_marginRight="@dimen/settings_checkbox_margin" android:layout_marginRight="@dimen/settings_checkbox_margin"
android:singleLine="true" android:singleLine="true"
android:text="@string/settings_enable_proxy" /> android:text="@string/settings_enable_proxy"
android:textSize="@dimen/settings_checkbox_textsize" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -365,7 +401,8 @@
android:paddingLeft="@dimen/settings_layout_padding" android:paddingLeft="@dimen/settings_layout_padding"
android:paddingRight="@dimen/settings_layout_padding" android:paddingRight="@dimen/settings_layout_padding"
android:singleLine="true" android:singleLine="true"
android:text="@string/settings_enable_proxy_auth" /> android:text="@string/settings_enable_proxy_auth"
android:textSize="@dimen/settings_checkbox_textsize" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -83,7 +83,7 @@
<string name="error_image_save">Fehler beim Speichern!</string> <string name="error_image_save">Fehler beim Speichern!</string>
<string name="error_not_authorized">Keine Berechtigung!</string> <string name="error_not_authorized">Keine Berechtigung!</string>
<string name="error_file_format">Dateiformat nicht unterstützt!</string> <string name="error_file_format">Dateiformat nicht unterstützt!</string>
<string name="load_answer">Antworten laden</string> <string name="settings_enable_ans_load">Antworten laden</string>
<string name="info_tweet_retweeted">Tweet retweeted!</string> <string name="info_tweet_retweeted">Tweet retweeted!</string>
<string name="info_tweet_unretweeted">Retweet entfernt!</string> <string name="info_tweet_unretweeted">Retweet entfernt!</string>
<string name="info_tweet_favored">Tweet favorisiert!</string> <string name="info_tweet_favored">Tweet favorisiert!</string>
@ -171,4 +171,5 @@
<string name="menu_write_message">Direktnachricht</string> <string name="menu_write_message">Direktnachricht</string>
<string name="menu_follow_user">Nutzer folgen</string> <string name="menu_follow_user">Nutzer folgen</string>
<string name="menu_goto_lists">Nutzerlisten</string> <string name="menu_goto_lists">Nutzerlisten</string>
<string name="settings_enable_hq_img">hochauflösend</string>
</resources> </resources>

View File

@ -6,6 +6,7 @@
<!--dimens of page_settings.xml--> <!--dimens of page_settings.xml-->
<dimen name="settings_toolbar_height">@dimen/toolbar_height</dimen> <dimen name="settings_toolbar_height">@dimen/toolbar_height</dimen>
<dimen name="settings_checkbox_margin">@dimen/settings_layout_padding</dimen> <dimen name="settings_checkbox_margin">@dimen/settings_layout_padding</dimen>
<dimen name="settings_checkbox_textsize">13sp</dimen>
<dimen name="settings_divider">2dp</dimen> <dimen name="settings_divider">2dp</dimen>
<dimen name="settings_info_appname_font">18sp</dimen> <dimen name="settings_info_appname_font">18sp</dimen>
<dimen name="settings_layout_padding">10dp</dimen> <dimen name="settings_layout_padding">10dp</dimen>

View File

@ -53,7 +53,7 @@
<string name="confirm_discard">discard changes?</string> <string name="confirm_discard">discard changes?</string>
<string name="user_data">User data</string> <string name="user_data">User data</string>
<string name="follows_you">follows you</string> <string name="follows_you">follows you</string>
<string name="load_answer">answer load</string> <string name="settings_enable_ans_load">answer load</string>
<string name="proxy_settings">Proxy settings</string> <string name="proxy_settings">Proxy settings</string>
<string name="enter_proxy">Proxy IP address</string> <string name="enter_proxy">Proxy IP address</string>
<string name="proxy_port">Port</string> <string name="proxy_port">Port</string>
@ -78,6 +78,7 @@
<string name="profile_banner">Profile banner image</string> <string name="profile_banner">Profile banner image</string>
<string name="editprofile_add_banner">add banner</string> <string name="editprofile_add_banner">add banner</string>
<string name="settings_3rd_party_license">App and 3rd party license:</string> <string name="settings_3rd_party_license">App and 3rd party license:</string>
<string name="settings_enable_hq_img">High resolution</string>
<string name="settings_info_license_link" translatable="false">http://www.apache.org/licenses/LICENSE-2.0</string> <string name="settings_info_license_link" translatable="false">http://www.apache.org/licenses/LICENSE-2.0</string>
<string name="settings_info_github">App on GitHub:</string> <string name="settings_info_github">App on GitHub:</string>
<string name="badge_twitter4j" translatable="false">Twitter4J Badge</string> <string name="badge_twitter4j" translatable="false">Twitter4J Badge</string>