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 10 years ago
parent
commit
6c4058851c
  1. 154
      core/res/layout/actionbar_serverstatus.xml
  2. 54
      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 @@ @@ -15,85 +15,95 @@
You should have received a copy of the GNU General Public License
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"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectable_background_transdroid"
android:clickable="true"
android:paddingRight="@dimen/margin_default"
android:paddingTop="@dimen/ui_serverstatus_margin" >
android:layout_width="match_parent" >
<TextView
android:id="@+id/upcount_sign"
<RelativeLayout
android:id="@+id/speedswrapper_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↑"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText" />
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="?attr/selectable_background_transdroid"
android:clickable="true"
android:focusable="true"
android:paddingLeft="@dimen/margin_default"
android:paddingRight="@dimen/margin_default"
android:paddingTop="@dimen/ui_serverstatus_margin"
tools:ignore="UselessParent" >
<TextView
android:id="@+id/upcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_bignumber" />
<TextView
android:id="@+id/upcount_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↑"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/downcount_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_text"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↓"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/upcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_bignumber" />
<TextView
android:id="@+id/downcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/downcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_bignumber" />
<TextView
android:id="@+id/downcount_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_text"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↓"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_sign"
android:visibility="invisible"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/upspeed_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/upcount_text"
android:layout_alignParentRight="true"
android:layout_below="@id/upcount_text"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
<TextView
android:id="@+id/downcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/downcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_bignumber" />
<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="end"
android:textColor="?attr/text_bright"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
<TextView
android:id="@+id/upspeed_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/upcount_text"
android:layout_alignParentRight="true"
android:layout_below="@id/upcount_text"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:textColor="?attr/text_bright"
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>

54
core/res/layout/dialog_transferrates.xml

@ -198,12 +198,12 @@ @@ -198,12 +198,12 @@
android:text="@string/status_maxspeed_unit"
android:textAllCaps="true" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="#28000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -306,4 +306,52 @@ @@ -306,4 +306,52 @@
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>

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

@ -0,0 +1,22 @@ @@ -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 @@ @@ -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/>. @@ -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_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_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_stillloadingdetails">Even wachten tot de torrentdetails zijn geladen</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 @@ @@ -55,8 +55,8 @@
<style name="BigNumberButton" parent="android:Widget.Holo">
<item name="android:background">@drawable/selectable_background_transdroid</item>
<item name="android:padding">@dimen/margin_half</item>
<item name="android:textSize">32sp</item>
<item name="android:padding">@dimen/ui_bignumber_padding</item>
<item name="android:textSize">@dimen/ui_bignumber_size</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>

2
core/res/values/dimens.xml

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

2
core/res/values/strings.xml

@ -419,7 +419,7 @@ @@ -419,7 +419,7 @@
<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_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_stillloadingdetails">Please wait until the torrent details have been loaded</string>
<string name="error_noftpapp">No app found that can download %1$s</string>

4
core/res/values/styles.xml

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

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

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

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

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

Loading…
Cancel
Save