Skip to content

Commit

Permalink
InfoActivity: Zoom and ProgressBar for WebView (opacapp#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Jan 23, 2013
1 parent 9841599 commit 7a4b499
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
</activity>
<activity
android:name=".frontend.InfoActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/info" >
</activity>
<activity
Expand Down
14 changes: 12 additions & 2 deletions res/layout/info_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@
<TextView
android:id="@+id/tvErr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:padding="10dp"
android:visibility="gone" />

<WebView
android:id="@+id/wvInfo"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:layout_weight="1" />

<org.holoeverywhere.widget.ProgressBar
android:id="@+id/pbWebProgress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dip" />

</LinearLayout>
17 changes: 17 additions & 0 deletions src/de/geeksfactory/opacclient/frontend/InfoActivity.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package de.geeksfactory.opacclient.frontend;

import org.holoeverywhere.widget.ProgressBar;
import org.json.JSONException;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.TextView;

Expand Down Expand Up @@ -52,6 +54,21 @@ public void onCreate(Bundle savedInstanceState) {

SlidingMenu sm = getSlidingMenu();
sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);

wvInfo = (WebView) findViewById(R.id.wvInfo);
wvInfo.getSettings().setSupportZoom(true);
wvInfo.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
ProgressBar Pbar = (ProgressBar) findViewById(R.id.pbWebProgress);
if (progress < 100 && Pbar.getVisibility() == ProgressBar.GONE) {
Pbar.setVisibility(ProgressBar.VISIBLE);
}
Pbar.setProgress(progress);
if (progress == 100) {
Pbar.setVisibility(ProgressBar.GONE);
}
}
});
}

@Override
Expand Down

0 comments on commit 7a4b499

Please sign in to comment.