Skip to content

Commit

Permalink
Fixed problem where progress bar didn't display on 4.0 and 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonycr committed Feb 6, 2015
1 parent 10668a0 commit db20a4e
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 87 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="acr.browser.lightning"
android:versionCode="70"
android:versionName="4.0.2a" >
android:versionCode="71"
android:versionName="4.0.3a" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
Expand Down
1 change: 0 additions & 1 deletion src/acr/browser/lightning/AnimatedProgressBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ protected void applyTransformation(float interpolatedTime, Transformation t) {
mProgressView.getLayoutParams().width = width;
mProgressView.requestLayout();
}
mProgressView.invalidate();
}

@Override
Expand Down
179 changes: 95 additions & 84 deletions src/acr/browser/lightning/BrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import android.util.TypedValue;
import android.view.*;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnKeyListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
Expand Down Expand Up @@ -87,6 +88,8 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
private LightningViewAdapter mTitleAdapter;
private List<HistoryItem> mBookmarkList;
private BookmarkViewAdapter mBookmarkAdapter;
private DrawerArrowDrawable mArrowDrawable;
private ImageView mArrowImage;
private AutoCompleteTextView mSearch;
private ClickHandler mClickHandler;
private AnimatedProgressBar mProgressBar;
Expand Down Expand Up @@ -227,9 +230,9 @@ private synchronized void initialize() {

// TODO

final DrawerArrowDrawable drawable = new DrawerArrowDrawable(this);
final ImageView arrow = (ImageView) mActionBar.getCustomView().findViewById(R.id.arrow);
arrow.setImageDrawable(drawable);
mArrowDrawable = new DrawerArrowDrawable(this);
mArrowImage = (ImageView) mActionBar.getCustomView().findViewById(R.id.arrow);
mArrowImage.setImageDrawable(mArrowDrawable);
LinearLayout arrowButton = (LinearLayout) mActionBar.getCustomView().findViewById(
R.id.arrow_button);
arrowButton.setOnClickListener(new OnClickListener() {
Expand Down Expand Up @@ -290,8 +293,65 @@ public void onClick(View v) {
mCopyIcon.setBounds(0, 0, Utils.convertDpiToPixels(mContext, 24),
Utils.convertDpiToPixels(mContext, 24));
mIcon = mRefreshIcon;
SearchClass search = new SearchClass();
mSearch.setCompoundDrawables(null, null, mRefreshIcon, null);
mSearch.setOnKeyListener(new OnKeyListener() {
mSearch.setOnKeyListener(search.new KeyListener());
mSearch.setOnFocusChangeListener(search.new FocusChangeListener());
mSearch.setOnEditorActionListener(search.new EditorActionListener());
mSearch.setOnTouchListener(search.new TouchListener());

mSystemBrowser = getSystemBrowser();
Thread initialize = new Thread(new Runnable() {

@Override
public void run() {
initializeSearchSuggestions(mSearch);
}

});
initialize.run();

mNewTab.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
newTab(null, true);
}

});

mNewTab.setOnLongClickListener(new OnLongClickListener() {

@Override
public boolean onLongClick(View v) {
String url = mPreferences.getString(PreferenceConstants.SAVE_URL, null);
if (url != null) {
newTab(url, true);
Toast.makeText(mContext, R.string.deleted_tab, Toast.LENGTH_SHORT).show();
}
mEditPrefs.putString(PreferenceConstants.SAVE_URL, null).apply();
return true;
}

});

// mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START);
initializePreferences();
initializeTabs();

if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
}

checkForTor();

}

private class SearchClass {

public class KeyListener implements OnKeyListener {

@Override
public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
Expand All @@ -311,9 +371,31 @@ public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
return false;
}

});
mSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() {
}

public class EditorActionListener implements OnEditorActionListener {
@Override
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
// hide the keyboard and search the web when the enter key
// button is pressed
if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE
|| actionId == EditorInfo.IME_ACTION_NEXT
|| actionId == EditorInfo.IME_ACTION_SEND
|| actionId == EditorInfo.IME_ACTION_SEARCH
|| (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
return true;
}
return false;
}
}

public class FocusChangeListener implements OnFocusChangeListener {
@Override
public void onFocusChange(View v, final boolean hasFocus) {
if (!hasFocus && mCurrentView != null) {
Expand All @@ -336,9 +418,9 @@ public void onFocusChange(View v, final boolean hasFocus) {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if (!hasFocus) {
drawable.setProgress(1.0f - interpolatedTime);
mArrowDrawable.setProgress(1.0f - interpolatedTime);
} else {
drawable.setProgress(interpolatedTime);
mArrowDrawable.setProgress(interpolatedTime);
}
}

Expand All @@ -359,9 +441,9 @@ public void onAnimationStart(Animation animation) {
@Override
public void onAnimationEnd(Animation animation) {
if (!hasFocus) {
drawable.setProgress(0.0f);
mArrowDrawable.setProgress(0.0f);
} else {
drawable.setProgress(1.0f);
mArrowDrawable.setProgress(1.0f);
}
}

Expand All @@ -374,7 +456,7 @@ public void onAnimationRepeat(Animation animation) {

@Override
public void run() {
arrow.startAnimation(anim);
mArrowImage.startAnimation(anim);
}

}, 100);
Expand All @@ -384,32 +466,9 @@ public void run() {
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
}
}
});
mSearch.setOnEditorActionListener(new OnEditorActionListener() {

@Override
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
// hide the keyboard and search the web when the enter key
// button is pressed
if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE
|| actionId == EditorInfo.IME_ACTION_NEXT
|| actionId == EditorInfo.IME_ACTION_SEND
|| actionId == EditorInfo.IME_ACTION_SEARCH
|| (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
return true;
}
return false;
}

});
}

mSearch.setOnTouchListener(new OnTouchListener() {
public class TouchListener implements OnTouchListener {

@SuppressLint("ClickableViewAccessibility")
@Override
Expand Down Expand Up @@ -438,55 +497,7 @@ public boolean onTouch(View v, MotionEvent event) {
return false;
}

});

mSystemBrowser = getSystemBrowser();
Thread initialize = new Thread(new Runnable() {

@Override
public void run() {
initializeSearchSuggestions(mSearch);
}

});
initialize.run();

mNewTab.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
newTab(null, true);
}

});

mNewTab.setOnLongClickListener(new OnLongClickListener() {

@Override
public boolean onLongClick(View v) {
String url = mPreferences.getString(PreferenceConstants.SAVE_URL, null);
if (url != null) {
newTab(url, true);
Toast.makeText(mContext, R.string.deleted_tab, Toast.LENGTH_SHORT).show();
}
mEditPrefs.putString(PreferenceConstants.SAVE_URL, null).apply();
return true;
}

});

// mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START);
initializePreferences();
initializeTabs();

if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
}

checkForTor();

}

private class DrawerLocker implements DrawerListener {
Expand Down

0 comments on commit db20a4e

Please sign in to comment.