Merge remote-tracking branch 'remotes/upstream/master'

This commit is contained in:
Elad Keyshawn 2016-04-10 09:38:39 +03:00
commit 7cbaa1c73f
4 changed files with 40 additions and 94 deletions

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/contentHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_toLeftOf="@+id/deleteButton"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:maxLines="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
xmlns:android="http://schemas.android.com/apk/res/android"/>

View File

@ -1,69 +0,0 @@
package org.kiwix.kiwixmobile;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
@SuppressLint("ValidFragment")
public class BookmarkDialogFragment extends DialogFragment {
private BookmarkDialogListener listen;
private String[] contents;
private boolean isBookmarked;
public BookmarkDialogFragment(String[] contents, boolean isBookmarked) {
this.contents = contents;
this.isBookmarked = isBookmarked;
}
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder build = new AlertDialog.Builder(getActivity());
//build.setTitle(R.string.menu_bookmarks);
String buttonText;
if (isBookmarked) {
buttonText = getResources().getString(R.string.remove_bookmark);
} else {
buttonText = getResources().getString(R.string.add_bookmark);
}
if (contents.length != 0) {
build.setItems(contents, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int choice) {
listen.onListItemSelect(contents[choice]);
}
});
}
build.setNeutralButton(buttonText, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int choice) {
listen.onBookmarkButtonPressed();
}
});
return build.create();
}
@Override
public void onAttach(Activity a) {
super.onAttach(a);
try {
listen = (BookmarkDialogListener) a;
} catch (ClassCastException e) {
throw new ClassCastException(a.toString()
+ " must implement BookmarkDialogListener");
}
}
public interface BookmarkDialogListener {
public void onListItemSelect(String choice);
public void onBookmarkButtonPressed();
}
}

View File

@ -214,6 +214,8 @@ public class KiwixMobileActivity extends AppCompatActivity {
private int tempVisitCount;
public static TextView headerView;
@Override
public void onActionModeStarted(ActionMode mode) {
if (mActionMode == null) {
@ -333,6 +335,24 @@ public class KiwixMobileActivity extends AppCompatActivity {
mRightDrawerList = (ListView) findViewById(R.id.right_drawer_list);
mRightDrawerList.setDivider(null);
mRightDrawerList.setDividerHeight(0);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.content_header, null);
headerView = (TextView) view.findViewById(R.id.contentHeader);
headerView.setText(R.string.no_section_info);
headerView.setPadding((int) (26 * getResources().getDisplayMetrics().density), 0, 0, 0);
headerView.setBackgroundColor(Color.LTGRAY);
headerView.setTypeface(Typeface.DEFAULT_BOLD);
headerView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getCurrentWebView().setScrollY(0);
mRightDrawerLayout.closeDrawer(Gravity.RIGHT);
}
});
mRightDrawerList.addHeaderView(headerView);
mRightDrawerList.setAdapter(mRightArrayAdapter);
TextView tView = (TextView) findViewById(R.id.empty);
mRightDrawerList.setEmptyView(tView);

View File

@ -1,20 +1,16 @@
package org.kiwix.kiwixmobile.utils;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Handler;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.widget.ArrayAdapter;
import android.widget.HeaderViewListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.util.List;
import org.kiwix.kiwixmobile.KiwixMobileActivity;
import org.kiwix.kiwixmobile.R;
public class HTMLUtils {
@ -23,14 +19,11 @@ public class HTMLUtils {
private ArrayAdapter arrayAdapter;
private KiwixMobileActivity context;
private Handler mHandler;
private ListView mRightListView;
private TextView headerView;
public HTMLUtils(List<KiwixMobileActivity.SectionProperties> sectionProperties, List<TextView> textViews, ListView listView, KiwixMobileActivity context, Handler handler) {
this.sectionProperties = sectionProperties;
this.textViews = textViews;
this.mRightListView = listView;
this.arrayAdapter = (ArrayAdapter) listView.getAdapter();
this.arrayAdapter = ((ArrayAdapter)((HeaderViewListAdapter)listView.getAdapter()).getWrappedAdapter());
this.context = context;
this.mHandler = handler;
}
@ -50,22 +43,7 @@ public class HTMLUtils {
@Override
public void run() {
if (element.equals("H1")) {
mRightListView.removeHeaderView(headerView);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.section_list, null);
headerView = (TextView) view.findViewById(R.id.textTab);
headerView.setText(sectionTitle);
headerView.setPadding((int) (26 * context.getResources().getDisplayMetrics().density), 0, 0, 0);
headerView.setBackgroundColor(Color.LTGRAY);
headerView.setTypeface(Typeface.DEFAULT_BOLD);
headerView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
context.getCurrentWebView().setScrollY(0);
context.mRightDrawerLayout.closeDrawer(Gravity.RIGHT);
}
});
mRightListView.addHeaderView(headerView);
KiwixMobileActivity.headerView.setText(sectionTitle);
} else {
textViews.add(i, new TextView(context));
sectionProperties.add(i, new KiwixMobileActivity.SectionProperties());