Eric Kok
11 years ago
20 changed files with 501 additions and 22 deletions
@ -0,0 +1,293 @@
@@ -0,0 +1,293 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical" > |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginLeft="@dimen/margin_half" |
||||
android:layout_marginRight="@dimen/margin_half" |
||||
android:orientation="horizontal" > |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginRight="@dimen/margin_half" |
||||
android:text="@string/status_maxspeed_down" |
||||
android:textAllCaps="true" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/maxspeeddown_text" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:gravity="right" |
||||
android:singleLine="true" |
||||
android:text="-" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginRight="@dimen/margin_half" |
||||
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" |
||||
android:orientation="horizontal" > |
||||
|
||||
<Button |
||||
android:id="@+id/down1Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="1" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/down2Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="2" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/down3Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="3" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/down4Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="4" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/down5Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="5" |
||||
tools:ignore="HardcodedText" /> |
||||
</LinearLayout> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal" > |
||||
|
||||
<Button |
||||
android:id="@+id/down6Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="6" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/down7Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="7" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/down8Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="8" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/down9Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="9" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/down0Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="0" |
||||
tools:ignore="HardcodedText" /> |
||||
</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" |
||||
android:layout_marginLeft="@dimen/margin_half" |
||||
android:layout_marginRight="@dimen/margin_half" |
||||
android:orientation="horizontal" > |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginRight="@dimen/margin_half" |
||||
android:text="@string/status_maxspeed_up" |
||||
android:textAllCaps="true" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/maxspeedup_text" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:gravity="right" |
||||
android:singleLine="true" |
||||
android:text="-" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<TextView |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginRight="@dimen/margin_half" |
||||
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" |
||||
android:orientation="horizontal" > |
||||
|
||||
<Button |
||||
android:id="@+id/up1Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="1" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/up2Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="2" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/up3Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="3" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/up4Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="4" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/up5Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="5" |
||||
tools:ignore="HardcodedText" /> |
||||
</LinearLayout> |
||||
|
||||
<LinearLayout |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal" > |
||||
|
||||
<Button |
||||
android:id="@+id/up6Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="6" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/up7Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="7" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/up8Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="8" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/up9Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="9" |
||||
tools:ignore="HardcodedText" /> |
||||
|
||||
<Button |
||||
android:id="@+id/up0Button" |
||||
style="@style/BigNumberButton" |
||||
android:layout_width="0dip" |
||||
android:layout_height="wrap_content" |
||||
android:layout_weight="1" |
||||
android:text="0" |
||||
tools:ignore="HardcodedText" /> |
||||
</LinearLayout> |
||||
|
||||
</LinearLayout> |
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
package org.transdroid.core.gui.navigation; |
||||
|
||||
import org.transdroid.core.R; |
||||
|
||||
import android.annotation.TargetApi; |
||||
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.widget.Button; |
||||
import android.widget.TextView; |
||||
|
||||
/** |
||||
* A dialog fragment that allow picking of maximum download and upload transfer rates as well as the resetting of these |
||||
* values. |
||||
* @author Eric Kok |
||||
*/ |
||||
public class SetTransferRatesDialog extends DialogFragment { |
||||
|
||||
private OnRatesPickedListener onRatesPicked; |
||||
private TextView maxSpeedDown, maxSpeedUp; |
||||
|
||||
public SetTransferRatesDialog() { |
||||
setRetainInstance(true); |
||||
} |
||||
|
||||
/** |
||||
* Sets the callback for results in this dialog (with newly selected values or a reset). |
||||
* @param onRatesPicked The event listener to this dialog |
||||
* @return This dialog, for method chaining |
||||
*/ |
||||
public SetTransferRatesDialog setOnRatesPicked(OnRatesPickedListener onRatesPicked) { |
||||
this.onRatesPicked = onRatesPicked; |
||||
return this; |
||||
} |
||||
|
||||
@Override |
||||
public Dialog onCreateDialog(Bundle savedInstanceState) { |
||||
final View transferRatesContent = getActivity().getLayoutInflater().inflate(R.layout.dialog_transferrates, |
||||
null, false); |
||||
maxSpeedDown = (TextView) transferRatesContent.findViewById(R.id.maxspeeddown_text); |
||||
maxSpeedUp = (TextView) transferRatesContent.findViewById(R.id.maxspeedup_text); |
||||
bindButtons(transferRatesContent, maxSpeedDown, R.id.down1Button, R.id.down2Button, R.id.down3Button, |
||||
R.id.down4Button, R.id.down5Button, R.id.down6Button, R.id.down7Button, R.id.down8Button, |
||||
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) { |
||||
onRatesPicked.onInvalidNumber(); |
||||
} |
||||
onRatesPicked.onRatesPicked(maxDown, maxUp); |
||||
} |
||||
}).setNeutralButton(R.string.status_maxspeed_reset, new OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, int which) { |
||||
onRatesPicked.resetRates(); |
||||
} |
||||
}).setNegativeButton(android.R.string.cancel, null).create(); |
||||
} |
||||
|
||||
private void bindButtons(View transferRatesContent, View numberView, int... buttonResource) { |
||||
for (int i : buttonResource) { |
||||
// Keep the relevant number as reference in the view tag and bind the click listerner
|
||||
transferRatesContent.findViewById(i).setTag(numberView); |
||||
transferRatesContent.findViewById(i).setOnClickListener(onNumberClicked); |
||||
} |
||||
} |
||||
|
||||
private android.view.View.OnClickListener onNumberClicked = new android.view.View.OnClickListener() { |
||||
@Override |
||||
public void onClick(View v) { |
||||
// Append the text contents of the button itself as text to the current number (as reference in the view's
|
||||
// tag)
|
||||
TextView numberView = (TextView) v.getTag(); |
||||
if (numberView.getText().equals("-")) |
||||
numberView.setText(""); |
||||
numberView.setText(numberView.getText().toString() + ((Button) v).getText().toString()); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* Listener interface to the user having picked or wanting to resets the current maximum transfer speeds; |
||||
*/ |
||||
public interface OnRatesPickedListener { |
||||
public void onRatesPicked(int maxDownloadSpeed, int maxUploadSpeed); |
||||
public void resetRates(); |
||||
public void onInvalidNumber(); |
||||
} |
||||
|
||||
} |
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="100" android:versionName="4.2.0" package="com.actionbarsherlock"> |
||||
|
||||
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="16"/> |
||||
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="18"/> |
||||
|
||||
</manifest> |
||||
|
Loading…
Reference in new issue