Browse Source

Fixed transfer rates dialog size on layouts with a small height (such as phone landscape views). Fixes #74.!

pull/148/merge
Eric Kok 11 years ago
parent
commit
6c4058851c
  1. 154
      core/res/layout/actionbar_serverstatus.xml
  2. 48
      core/res/layout/dialog_transferrates.xml
  3. 22
      core/res/values-h400dp/dimens.xml
  4. 22
      core/res/values-h600dp/dimens.xml
  5. 2
      core/res/values-nl/strings.xml
  6. 4
      core/res/values-v16/styles.xml
  7. 2
      core/res/values/dimens.xml
  8. 2
      core/res/values/strings.xml
  9. 4
      core/res/values/styles.xml
  10. 15
      core/src/org/transdroid/core/gui/ServerStatusView.java
  11. 59
      core/src/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java

154
core/res/layout/actionbar_serverstatus.xml

@ -15,85 +15,95 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
--> -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/selectable_background_transdroid" android:layout_width="match_parent" >
android:clickable="true"
android:paddingRight="@dimen/margin_default"
android:paddingTop="@dimen/ui_serverstatus_margin" >
<TextView <RelativeLayout
android:id="@+id/upcount_sign" android:id="@+id/speedswrapper_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_alignParentRight="true" android:layout_gravity="right"
android:fontFamily="sans-serif-light" android:background="?attr/selectable_background_transdroid"
android:paddingTop="@dimen/ui_serverstatus_signmargin" android:clickable="true"
android:text="↑" android:focusable="true"
android:textColor="?attr/text_bright" android:paddingLeft="@dimen/margin_default"
android:textSize="@dimen/ui_serverstatus_sign" android:paddingRight="@dimen/margin_default"
android:visibility="invisible" android:paddingTop="@dimen/ui_serverstatus_margin"
tools:ignore="HardcodedText" /> tools:ignore="UselessParent" >
<TextView <TextView
android:id="@+id/upcount_text" android:id="@+id/upcount_sign"
android:layout_width="@dimen/ui_serverstatus_width" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_sign" android:layout_alignParentRight="true"
android:fontFamily="sans-serif-light" android:fontFamily="sans-serif-light"
android:gravity="end" android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:textColor="?attr/text_bright" android:text="↑"
android:textSize="@dimen/ui_serverstatus_bignumber" /> android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/downcount_sign" android:id="@+id/upcount_text"
android:layout_width="wrap_content" android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_text" android:layout_toLeftOf="@id/upcount_sign"
android:fontFamily="sans-serif-light" android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin" android:gravity="right"
android:text="↓" android:textColor="?attr/text_bright"
android:textColor="?attr/text_bright" android:textSize="@dimen/ui_serverstatus_bignumber" />
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/downcount_text" android:id="@+id/downcount_sign"
android:layout_width="@dimen/ui_serverstatus_width" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/downcount_sign" android:layout_toLeftOf="@id/upcount_text"
android:fontFamily="sans-serif-light" android:fontFamily="sans-serif-light"
android:gravity="end" android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:textColor="?attr/text_bright" android:text="↓"
android:textSize="@dimen/ui_serverstatus_bignumber" /> android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/upspeed_text" android:id="@+id/downcount_text"
android:layout_width="wrap_content" android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@id/upcount_text" android:layout_toLeftOf="@id/downcount_sign"
android:layout_alignParentRight="true" android:fontFamily="sans-serif-light"
android:layout_below="@id/upcount_text" android:gravity="right"
android:layout_marginTop="-4dip" android:textColor="?attr/text_bright"
android:fontFamily="sans-serif-light" android:textSize="@dimen/ui_serverstatus_bignumber" />
android:gravity="end"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
<TextView <TextView
android:id="@+id/downspeed_text" android:id="@+id/upspeed_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@id/downcount_text" android:layout_alignLeft="@id/upcount_text"
android:layout_alignRight="@id/downcount_sign" android:layout_alignParentRight="true"
android:layout_below="@id/downcount_text" android:layout_below="@id/upcount_text"
android:layout_marginTop="-4dip" android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light" android:fontFamily="sans-serif-light"
android:gravity="end" android:gravity="right"
android:textColor="?attr/text_bright" android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_smallnumber" /> android:textSize="@dimen/ui_serverstatus_smallnumber" />
<TextView
android:id="@+id/downspeed_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/downcount_text"
android:layout_alignRight="@id/downcount_sign"
android:layout_below="@id/downcount_text"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
</RelativeLayout>
</RelativeLayout> </FrameLayout>

48
core/res/layout/dialog_transferrates.xml

@ -306,4 +306,52 @@
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="#28000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal" >
<Button
android:id="@+id/cancel_button"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectable_background_transdroid"
android:textSize="14sp"
android:text="@android:string/cancel" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="#28000000" />
<Button
android:id="@+id/reset_button"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:background="?attr/selectable_background_transdroid"
android:text="@string/status_maxspeed_reset" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="#28000000" />
<Button
android:id="@+id/ok_button"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="14sp"
android:background="?attr/selectable_background_transdroid"
android:text="@android:string/ok" />
</LinearLayout>
</LinearLayout> </LinearLayout>

22
core/res/values-h400dp/dimens.xml

@ -0,0 +1,22 @@
<!--
Copyright 2010-2013 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Transdroid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<dimen name="ui_bignumber_size">35sp</dimen>
<dimen name="ui_bignumber_padding">3dp</dimen>
</resources>

22
core/res/values-h600dp/dimens.xml

@ -0,0 +1,22 @@
<!--
Copyright 2010-2013 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Transdroid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<resources>
<dimen name="ui_bignumber_size">55sp</dimen>
<dimen name="ui_bignumber_padding">5dp</dimen>
</resources>

2
core/res/values-nl/strings.xml

@ -310,7 +310,7 @@ along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
<string name="error_no_valid_settings_file">Het bestand lijkt geen %1$s-instellingen te bevatten</string> <string name="error_no_valid_settings_file">Het bestand lijkt geen %1$s-instellingen te bevatten</string>
<string name="error_file_not_found">Het bestand met instellingen kon niet worden gevonden</string> <string name="error_file_not_found">Het bestand met instellingen kon niet worden gevonden</string>
<string name="error_cant_write_settings_file">Kan niet naar het bestand met instellingen schrijven</string> <string name="error_cant_write_settings_file">Kan niet naar het bestand met instellingen schrijven</string>
<string name="error_notanumber">Kies een positief getal</string> <string name="error_notanumber">Kies een positief getal voor beide snelheden</string>
<string name="error_notalabel">Geen een geldige labelnaam op of kies uit de lijst</string> <string name="error_notalabel">Geen een geldige labelnaam op of kies uit de lijst</string>
<string name="error_stillloadingdetails">Even wachten tot de torrentdetails zijn geladen</string> <string name="error_stillloadingdetails">Even wachten tot de torrentdetails zijn geladen</string>
<string name="error_noftpapp">Geen app gevonden die %1$s kan downloaden</string> <string name="error_noftpapp">Geen app gevonden die %1$s kan downloaden</string>

4
core/res/values-v16/styles.xml

@ -55,8 +55,8 @@
<style name="BigNumberButton" parent="android:Widget.Holo"> <style name="BigNumberButton" parent="android:Widget.Holo">
<item name="android:background">@drawable/selectable_background_transdroid</item> <item name="android:background">@drawable/selectable_background_transdroid</item>
<item name="android:padding">@dimen/margin_half</item> <item name="android:padding">@dimen/ui_bignumber_padding</item>
<item name="android:textSize">32sp</item> <item name="android:textSize">@dimen/ui_bignumber_size</item>
<item name="android:fontFamily">sans-serif-light</item> <item name="android:fontFamily">sans-serif-light</item>
</style> </style>

2
core/res/values/dimens.xml

@ -40,6 +40,8 @@
<dimen name="ui_serverstatus_sign">15dp</dimen> <dimen name="ui_serverstatus_sign">15dp</dimen>
<dimen name="ui_serverstatus_smallnumber">13dp</dimen> <dimen name="ui_serverstatus_smallnumber">13dp</dimen>
<dimen name="ui_serverstatus_width">56dp</dimen> <dimen name="ui_serverstatus_width">56dp</dimen>
<dimen name="ui_bignumber_size">20sp</dimen>
<dimen name="ui_bignumber_padding">2dp</dimen>
<!-- Widget configuration --> <!-- Widget configuration -->
<integer name="widget_config_orientation">1</integer> <integer name="widget_config_orientation">1</integer>

2
core/res/values/strings.xml

@ -419,7 +419,7 @@
<string name="error_no_valid_settings_file">File does not seem to contain %1$s settings</string> <string name="error_no_valid_settings_file">File does not seem to contain %1$s settings</string>
<string name="error_file_not_found">The settings file could not be found</string> <string name="error_file_not_found">The settings file could not be found</string>
<string name="error_cant_write_settings_file">Can\'t write to the settings file</string> <string name="error_cant_write_settings_file">Can\'t write to the settings file</string>
<string name="error_notanumber">Please enter a positive number</string> <string name="error_notanumber">Please enter a positive number for both speeds</string>
<string name="error_notalabel">Please enter a valid label or pick from the list</string> <string name="error_notalabel">Please enter a valid label or pick from the list</string>
<string name="error_stillloadingdetails">Please wait until the torrent details have been loaded</string> <string name="error_stillloadingdetails">Please wait until the torrent details have been loaded</string>
<string name="error_noftpapp">No app found that can download %1$s</string> <string name="error_noftpapp">No app found that can download %1$s</string>

4
core/res/values/styles.xml

@ -120,8 +120,8 @@
<style name="BigNumberButton" parent="android:Widget.Holo"> <style name="BigNumberButton" parent="android:Widget.Holo">
<item name="android:background">@drawable/selectable_background_transdroid</item> <item name="android:background">@drawable/selectable_background_transdroid</item>
<item name="android:padding">@dimen/margin_half</item> <item name="android:padding">@dimen/ui_bignumber_padding</item>
<item name="android:textSize">60sp</item> <item name="android:textSize">@dimen/ui_bignumber_size</item>
</style> </style>
</resources> </resources>

15
core/src/org/transdroid/core/gui/ServerStatusView.java

@ -38,6 +38,8 @@ public class ServerStatusView extends RelativeLayout implements OnRatesPickedLis
@ViewById @ViewById
protected TextView downcountText, upcountText, downcountSign, upcountSign, downspeedText, upspeedText; protected TextView downcountText, upcountText, downcountSign, upcountSign, downspeedText, upspeedText;
@ViewById
protected View speedswrapperLayout;
private TorrentsActivity activity; private TorrentsActivity activity;
public ServerStatusView(Context context) { public ServerStatusView(Context context) {
@ -63,7 +65,7 @@ public class ServerStatusView extends RelativeLayout implements OnRatesPickedLis
upspeedText.setText(null); upspeedText.setText(null);
downcountSign.setVisibility(View.INVISIBLE); downcountSign.setVisibility(View.INVISIBLE);
upcountSign.setVisibility(View.INVISIBLE); upcountSign.setVisibility(View.INVISIBLE);
setClickListener(null); speedswrapperLayout.setOnClickListener(null);
} }
int downcount = 0, upcount = 0, downspeed = 0, upspeed = 0; int downcount = 0, upcount = 0, downspeed = 0, upspeed = 0;
@ -87,17 +89,8 @@ public class ServerStatusView extends RelativeLayout implements OnRatesPickedLis
upspeedText.setText(FileSizeConverter.getSize(upspeed) + "/s"); upspeedText.setText(FileSizeConverter.getSize(upspeed) + "/s");
downcountSign.setVisibility(View.VISIBLE); downcountSign.setVisibility(View.VISIBLE);
upcountSign.setVisibility(View.VISIBLE); upcountSign.setVisibility(View.VISIBLE);
setClickListener(onStartDownPickerClicked); speedswrapperLayout.setOnClickListener(onStartDownPickerClicked);
}
private void setClickListener(OnClickListener onClick) {
downcountText.setOnClickListener(onClick);
upcountText.setOnClickListener(onClick);
downspeedText.setOnClickListener(onClick);
upspeedText.setOnClickListener(onClick);
downcountSign.setOnClickListener(onClick);
upcountSign.setOnClickListener(onClick);
} }
private OnClickListener onStartDownPickerClicked = new OnClickListener() { private OnClickListener onStartDownPickerClicked = new OnClickListener() {

59
core/src/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java

@ -20,13 +20,12 @@ import java.security.InvalidParameterException;
import org.transdroid.core.R; import org.transdroid.core.R;
import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
@ -68,27 +67,39 @@ public class SetTransferRatesDialog extends DialogFragment {
R.id.down9Button, R.id.down0Button); R.id.down9Button, R.id.down0Button);
bindButtons(transferRatesContent, maxSpeedUp, R.id.up1Button, R.id.up2Button, R.id.up3Button, R.id.up4Button, bindButtons(transferRatesContent, maxSpeedUp, R.id.up1Button, R.id.up2Button, R.id.up3Button, R.id.up4Button,
R.id.up5Button, R.id.up6Button, R.id.up7Button, R.id.up8Button, R.id.up9Button, R.id.up0Button); R.id.up5Button, R.id.up6Button, R.id.up7Button, R.id.up8Button, R.id.up9Button, R.id.up0Button);
return new AlertDialog.Builder(getActivity()).setTitle(R.string.status_maxspeed).setView(transferRatesContent) ((Button) transferRatesContent.findViewById(R.id.ok_button)).setOnClickListener(new OnClickListener() {
.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override
@Override public void onClick(View v) {
public void onClick(DialogInterface dialog, int which) { int maxDown = -1, maxUp = -1;
int maxDown = -1, maxUp = -1; try {
try { maxDown = Integer.parseInt(maxSpeedDown.getText().toString());
maxDown = Integer.parseInt(maxSpeedDown.getText().toString()); maxUp = Integer.parseInt(maxSpeedUp.getText().toString());
maxUp = Integer.parseInt(maxSpeedUp.getText().toString()); } catch (NumberFormatException e) {
} catch (NumberFormatException e) { }
} if (maxDown <= 0 || maxUp <= 0) {
if (maxDown <= 0 || maxUp <= 0) { onRatesPickedListener.onInvalidNumber();
onRatesPickedListener.onInvalidNumber(); }
} onRatesPickedListener.onRatesPicked(maxDown, maxUp);
onRatesPickedListener.onRatesPicked(maxDown, maxUp); dismiss();
} }
}).setNeutralButton(R.string.status_maxspeed_reset, new OnClickListener() { });
@Override ((Button) transferRatesContent.findViewById(R.id.reset_button)).setOnClickListener(new OnClickListener() {
public void onClick(DialogInterface dialog, int which) { @Override
onRatesPickedListener.resetRates(); public void onClick(View v) {
} onRatesPickedListener.resetRates();
}).setNegativeButton(android.R.string.cancel, null).create(); dismiss();
}
});
((Button) transferRatesContent.findViewById(R.id.cancel_button)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
Dialog dialog = new Dialog(getActivity());
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(transferRatesContent);
return dialog;
} }
private void bindButtons(View transferRatesContent, View numberView, int... buttonResource) { private void bindButtons(View transferRatesContent, View numberView, int... buttonResource) {

Loading…
Cancel
Save