Skip to content

Commit 63dadc1

Browse files
author
Arnav Gupta
committed
complete instapaper link handling in webview
1 parent 49510af commit 63dadc1

File tree

5 files changed

+97
-2
lines changed

5 files changed

+97
-2
lines changed

App/src/main/java/in/ac/dtu/subtlenews/InstapaperViewer.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import android.view.View;
1313
import android.view.MenuItem;
1414
import android.support.v4.app.NavUtils;
15+
import android.webkit.WebView;
16+
import android.widget.FrameLayout;
17+
import android.widget.LinearLayout;
1518

1619
/**
1720
* An example full-screen activity that shows and hides the system UI (i.e.
@@ -20,7 +23,7 @@
2023
* @see SystemUiHider
2124
*/
2225
public class InstapaperViewer extends Activity {
23-
26+
public String summaryUrl = "http://google.com";
2427

2528
/**
2629
* Whether or not the system UI should be auto-hidden after
@@ -57,8 +60,14 @@ protected void onCreate(Bundle savedInstanceState) {
5760
setContentView(R.layout.activity_instapaper_viewer);
5861
setupActionBar();
5962

63+
Bundle extras = getIntent().getExtras();
64+
if (extras != null) {
65+
summaryUrl = extras.getString("URL");
66+
}
67+
final WebView instapaperView = (WebView) findViewById(R.id.instapaper_viewer);
68+
6069
final View controlsView = findViewById(R.id.fullscreen_content_controls);
61-
final View contentView = findViewById(R.id.fullscreen_content);
70+
final View contentView = findViewById(R.id.instapaper_viewer);
6271

6372
// Set up an instance of SystemUiHider to control the system UI for
6473
// this activity.
@@ -99,6 +108,15 @@ public void onVisibilityChange(boolean visible) {
99108
// Schedule a hide().
100109
delayedHide(AUTO_HIDE_DELAY_MILLIS);
101110
}
111+
112+
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)instapaperView.getLayoutParams();
113+
if (visible) {
114+
params.setMargins(0, (int)(mControlsHeight*1.5), 0, 0); //substitute parameters for left, top, right, bottom
115+
} else {
116+
params.setMargins(0, 0, 0, 0);
117+
}
118+
instapaperView.setLayoutParams(params);
119+
102120
}
103121
});
104122

@@ -118,6 +136,9 @@ public void onClick(View view) {
118136
// operations to prevent the jarring behavior of controls going away
119137
// while interacting with the UI.
120138
findViewById(R.id.summary_back_button).setOnTouchListener(mDelayHideTouchListener);
139+
140+
141+
instapaperView.loadUrl(summaryUrl);
121142
}
122143

123144
@Override
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:background="#555555"
6+
tools:context="in.ac.dtu.subtlenews.InstapaperViewer">
7+
8+
<!-- The primary full-screen view. This can be replaced with whatever view
9+
is needed to present your content, e.g. VideoView, SurfaceView,
10+
TextureView, etc. -->
11+
<WebView android:id="@+id/instapaper_viewer"
12+
android:layout_width="fill_parent"
13+
android:layout_height="fill_parent"
14+
android:keepScreenOn="true"
15+
android:text="@string/dummy_content" />
16+
17+
<!-- This FrameLayout insets its children based on system windows using
18+
android:fitsSystemWindows. -->
19+
<FrameLayout android:layout_width="match_parent"
20+
android:layout_height="match_parent"
21+
android:fitsSystemWindows="true">
22+
23+
<LinearLayout android:id="@+id/fullscreen_content_controls"
24+
style="?metaButtonBarStyle"
25+
android:layout_width="match_parent"
26+
android:layout_height="wrap_content"
27+
android:layout_gravity="bottom|center_horizontal"
28+
android:background="@color/black_overlay"
29+
android:orientation="horizontal"
30+
tools:ignore="UselessParent">
31+
32+
<Button android:id="@+id/summary_back_button"
33+
style="?metaButtonBarButtonStyle"
34+
android:layout_width="0dp"
35+
android:layout_height="wrap_content"
36+
android:layout_weight="1"
37+
android:text="@string/summary_back_button" />
38+
39+
</LinearLayout>
40+
</FrameLayout>
41+
42+
</FrameLayout>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<resources>
2+
3+
<style name="FullscreenTheme" parent="android:Theme.Holo">
4+
<item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
5+
<item name="android:windowActionBarOverlay">true</item>
6+
<item name="android:windowBackground">@null</item>
7+
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
8+
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
9+
</style>
10+
11+
<style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar">
12+
<item name="android:background">@color/black_overlay</item>
13+
</style>
14+
15+
</resources>

App/src/main/res/values/attrs.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<resources>
2+
3+
<!-- Declare custom theme attributes that allow changing which styles are
4+
used for button bars depending on the API level.
5+
?android:attr/buttonBarStyle is new as of API 11 so this is
6+
necessary to support previous API levels. -->
7+
<declare-styleable name="ButtonBarContainerTheme">
8+
<attr name="metaButtonBarStyle" format="reference" />
9+
<attr name="metaButtonBarButtonStyle" format="reference" />
10+
</declare-styleable>
11+
12+
</resources>

App/src/main/res/values/colors.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
3+
<color name="black_overlay">#66000000</color>
4+
5+
</resources>

0 commit comments

Comments
 (0)