mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-10 16:02:05 -04:00
Android back and forward buttons gray out if unusable
This commit is contained in:
parent
f47f9406f4
commit
3bbcf57ca2
@ -55,7 +55,8 @@
|
|||||||
android:paddingLeft="4dp"
|
android:paddingLeft="4dp"
|
||||||
android:paddingRight="4dp"
|
android:paddingRight="4dp"
|
||||||
android:paddingTop="4dp"
|
android:paddingTop="4dp"
|
||||||
android:src="?attr/arrowBackDrawable"/>
|
android:src="?attr/arrowBackDrawable"
|
||||||
|
android:id="@+id/action_back_button" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@ -94,7 +95,8 @@
|
|||||||
android:paddingLeft="4dp"
|
android:paddingLeft="4dp"
|
||||||
android:paddingRight="4dp"
|
android:paddingRight="4dp"
|
||||||
android:paddingTop="4dp"
|
android:paddingTop="4dp"
|
||||||
android:src="?attr/arrowForwardDrawable"/>
|
android:src="?attr/arrowForwardDrawable"
|
||||||
|
android:id="@+id/action_forward_button" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@ import android.content.DialogInterface;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -628,7 +631,7 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
} else {
|
} else {
|
||||||
Log.e(TAG_KIWIX, "ZIM file doesn't exist at " + file.getAbsolutePath());
|
Log.e(TAG_KIWIX, "ZIM file doesn't exist at " + file.getAbsolutePath());
|
||||||
Toast.makeText(this, getResources().getString(R.string.error_filenotfound),
|
Toast.makeText(this, getResources().getString(R.string.error_filenotfound),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -976,10 +979,11 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
refreshBookmarkSymbol(menu);
|
refreshBookmarkSymbol(menu);
|
||||||
|
refreshNavigationButtons();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshBookmarkSymbol(Menu menu){
|
public void refreshBookmarkSymbol(Menu menu) {
|
||||||
if (menu.findItem(R.id.menu_bookmarks) != null &&
|
if (menu.findItem(R.id.menu_bookmarks) != null &&
|
||||||
getCurrentWebView().getUrl() != null &&
|
getCurrentWebView().getUrl() != null &&
|
||||||
!getCurrentWebView().getUrl().equals("file:///android_res/raw/help.html") &&
|
!getCurrentWebView().getUrl().equals("file:///android_res/raw/help.html") &&
|
||||||
@ -993,6 +997,26 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refreshNavigationButtons() {
|
||||||
|
ImageView back = (ImageView) mDrawerLayout.findViewById(R.id.action_back_button);
|
||||||
|
ImageView forward = (ImageView) mDrawerLayout.findViewById(R.id.action_forward_button);
|
||||||
|
toggleImageViewGrayFilter(back, getCurrentWebView().canGoBack());
|
||||||
|
toggleImageViewGrayFilter(forward, getCurrentWebView().canGoForward());
|
||||||
|
mDrawerLayout.findViewById(R.id.action_back).setEnabled(getCurrentWebView().canGoBack());
|
||||||
|
mDrawerLayout.findViewById(R.id.action_forward).setEnabled(getCurrentWebView().canGoForward());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleImageViewGrayFilter(ImageView image, boolean state) {
|
||||||
|
Drawable originalIcon = image.getDrawable();
|
||||||
|
Drawable res = originalIcon.mutate();
|
||||||
|
if (state) {
|
||||||
|
res.clearColorFilter();
|
||||||
|
} else {
|
||||||
|
res.setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN);
|
||||||
|
}
|
||||||
|
image.setImageDrawable(res);
|
||||||
|
}
|
||||||
|
|
||||||
public void loadPrefs() {
|
public void loadPrefs() {
|
||||||
|
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user