22
33import in .ac .dtu .subtlenews .util .SystemUiHider ;
44
5+ import android .annotation .SuppressLint ;
56import android .annotation .TargetApi ;
67import android .app .Activity ;
78import android .content .DialogInterface ;
1314import android .view .View ;
1415import android .view .MenuItem ;
1516import android .support .v4 .app .NavUtils ;
17+ import android .webkit .WebChromeClient ;
1618import android .webkit .WebView ;
1719import android .widget .Button ;
1820import android .widget .FrameLayout ;
1921import android .widget .LinearLayout ;
22+ import android .widget .ProgressBar ;
2023
2124import org .json .JSONException ;
2225import org .json .JSONObject ;
@@ -63,12 +66,17 @@ public class InstapaperViewer extends Activity {
6366 */
6467 private SystemUiHider mSystemUiHider ;
6568
69+ @ SuppressLint ("NewApi" )
6670 @ Override
6771 protected void onCreate (Bundle savedInstanceState ) {
6872 super .onCreate (savedInstanceState );
73+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT ) {
74+ setImmersive (true );
75+ }
76+ setTheme (R .style .AppTheme_NoActionBar );
6977
7078 setContentView (R .layout .activity_instapaper_viewer );
71- setupActionBar ();
79+ // setupActionBar();
7280
7381 Bundle extras = getIntent ().getExtras ();
7482 if (extras != null ) {
@@ -77,6 +85,25 @@ protected void onCreate(Bundle savedInstanceState) {
7785
7886 }
7987 final WebView instapaperView = (WebView ) findViewById (R .id .instapaper_viewer );
88+ final Activity activity = this ;
89+ final ProgressBar progressBar ;
90+ progressBar = (ProgressBar ) findViewById (R .id .progressBar );
91+
92+ instapaperView .setWebChromeClient (new WebChromeClient () {
93+ public void onProgressChanged (WebView view , int progress )
94+ {
95+ if (progress < 100 && progressBar .getVisibility () == ProgressBar .GONE ){
96+ progressBar .setVisibility (ProgressBar .VISIBLE );
97+ //txtview.setVisibility(View.VISIBLE);
98+ }
99+ progressBar .setProgress (progress );
100+ if (progress == 100 ) {
101+ progressBar .setVisibility (ProgressBar .GONE );
102+ //txtview.setVisibility(View.GONE);
103+ }
104+ }
105+ });
106+
80107
81108 final View controlsView = findViewById (R .id .fullscreen_content_controls );
82109 final View contentView = findViewById (R .id .instapaper_viewer );
@@ -97,7 +124,7 @@ protected void onCreate(Bundle savedInstanceState) {
97124 @ Override
98125 @ TargetApi (Build .VERSION_CODES .HONEYCOMB_MR2 )
99126 public void onVisibilityChange (boolean visible ) {
100- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .HONEYCOMB_MR2 ) {
127+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN ) {
101128 // If the ViewPropertyAnimator API is available
102129 // (Honeycomb MR2 and later), use it to animate the
103130 // in-layout UI controls at the bottom of the
@@ -124,13 +151,7 @@ public void onVisibilityChange(boolean visible) {
124151 delayedHide (AUTO_HIDE_DELAY_MILLIS );
125152 }
126153
127- FrameLayout .LayoutParams params = (FrameLayout .LayoutParams )instapaperView .getLayoutParams ();
128- if (visible ) {
129- params .setMargins (0 , (int )(mControlsHeight *1.5 ), 0 , 0 ); //substitute parameters for left, top, right, bottom
130- } else {
131- params .setMargins (0 , 0 , 0 , 0 );
132- }
133- instapaperView .setLayoutParams (params );
154+
134155
135156 }
136157 });
@@ -158,6 +179,7 @@ public void onClick(View view) {
158179 } catch (Exception e ) {
159180 e .printStackTrace ();
160181 }
182+
161183 instapaperView .loadUrl (summaryUrl );
162184 prevButton .setOnClickListener (new View .OnClickListener () {
163185 @ Override
@@ -197,13 +219,13 @@ protected void onPostCreate(Bundle savedInstanceState) {
197219 /**
198220 * Set up the {@link android.app.ActionBar}, if the API is available.
199221 */
200- @ TargetApi (Build .VERSION_CODES .HONEYCOMB )
222+ /* @TargetApi(Build.VERSION_CODES.JELLY_BEAN )
201223 private void setupActionBar() {
202- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .HONEYCOMB ) {
224+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN ) {
203225 // Show the Up button in the action bar.
204226 getActionBar().setDisplayHomeAsUpEnabled(true);
205227 }
206- }
228+ }*/
207229
208230 @ Override
209231 public boolean onOptionsItemSelected (MenuItem item ) {
0 commit comments