Skip to content

Commit

Permalink
Limit max. width on large screens (e.g. Galaxy Tab)
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Feb 8, 2011
1 parent 434e50c commit e8e0a57
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
* Copy to clipboard and open browser
* Allow cleartext password field
* Better notify user about empty input (flash/animate the TextEdit)
* Limit max. width on large screens (e.g. Galaxy Tab)
* Place Password Hash in notification area for quick access
16 changes: 8 additions & 8 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:paddingLeft="12dip"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content" android:paddingLeft="12dip"
android:paddingRight="12dip" android:paddingBottom="12dip">

<TextView android:layout_width="fill_parent"
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="@string/siteAddress" />
<EditText android:id="@+id/siteAddress" android:layout_width="fill_parent"
<EditText android:id="@+id/siteAddress" android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="@string/siteAddressHint"
android:inputType="textUri" />

<TextView android:layout_width="fill_parent"
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="@string/password" />
<EditText android:id="@+id/password" android:layout_width="fill_parent"
<EditText android:id="@+id/password" android:layout_width="match_parent"
android:layout_height="wrap_content" android:inputType="textPassword" />

<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content">
android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/hashedPassword"
android:paddingRight="4dip" />
Expand All @@ -25,7 +25,7 @@
</LinearLayout>

<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:paddingTop="4dip">

<Button android:text="@string/copyBtn" android:id="@+id/copyBtn"
Expand Down
4 changes: 4 additions & 0 deletions res/values/geometry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="maxWindowWidth">448dp</dimen>
</resources>
19 changes: 17 additions & 2 deletions src/com/uploadedlobster/PwdHash/PwdHashApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
import android.text.ClipboardManager;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
Expand All @@ -62,18 +64,31 @@ public class PwdHashApp extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getWindow().setLayout(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);

mSiteAddress = (EditText) findViewById(R.id.siteAddress);
mPassword = (EditText) findViewById(R.id.password);
mHashedPassword = (TextView) findViewById(R.id.hashedPassword);
mCopyBtn = (Button) findViewById(R.id.copyBtn);

setWindowGeometry();
handleIntents();
registerEventListeners();
}

private void setWindowGeometry() {
Window window = getWindow();
window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

int maxWidth = getResources().getDimensionPixelSize(
R.dimen.maxWindowWidth);

if (metrics.widthPixels > maxWidth) {
window.setLayout(maxWidth, LayoutParams.WRAP_CONTENT);
}
}

private void handleIntents() {
Intent intent = getIntent();
if (intent.getAction().equals(Intent.ACTION_SEND)) {
Expand Down

0 comments on commit e8e0a57

Please sign in to comment.