Improved table of contents UI on android

This commit is contained in:
Isaac 2016-04-02 20:39:20 +03:00
parent a3635a2541
commit 2bc9ad320d
3 changed files with 14 additions and 12 deletions

View File

@ -4,7 +4,9 @@
android:layout_height="56dp" android:layout_height="56dp"
android:background="?attr/selectedBackground" android:background="?attr/selectedBackground"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal"
android:clickable="false"
android:focusable="false">
<TextView <TextView
android:id="@+id/textTab" android:id="@+id/textTab"

View File

@ -53,4 +53,5 @@
<string name="no_reader_application_installed">Could not find an installed application for this type of file</string> <string name="no_reader_application_installed">Could not find an installed application for this type of file</string>
<string name="customapp_missing_content">Your application is corrupted.\nThis might happen when you remove files on the SD Card.\nYou need to uninstall then reinstall the App from the Play Store.</string> <string name="customapp_missing_content">Your application is corrupted.\nThis might happen when you remove files on the SD Card.\nYou need to uninstall then reinstall the App from the Play Store.</string>
<string name="go_to_play_store">Go to Play Store</string> <string name="go_to_play_store">Go to Play Store</string>
<string name="no_section_info">No Content Headers Found</string>
</resources> </resources>

View File

@ -298,9 +298,9 @@ public class KiwixMobileActivity extends AppCompatActivity
mRightDrawerList.setDivider(null); mRightDrawerList.setDivider(null);
mRightDrawerList.setDividerHeight(0); mRightDrawerList.setDividerHeight(0);
mRightDrawerList.setAdapter(mRightArrayAdapter); mRightDrawerList.setAdapter(mRightArrayAdapter);
TextView tView = (TextView) findViewById(R.id.empty);
mRightDrawerList.setEmptyView(tView);
sectionProperties = new ArrayList<SectionProperties>(); sectionProperties = new ArrayList<SectionProperties>();
//
// +mRightDrawerList.addHeaderView(tDiddy);
mRightArrayAdapter.notifyDataSetChanged(); mRightArrayAdapter.notifyDataSetChanged();
mLeftDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { mLeftDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@ -309,6 +309,13 @@ public class KiwixMobileActivity extends AppCompatActivity
selectTab(position); selectTab(position);
} }
}); });
mRightDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
getCurrentWebView().loadUrl("javascript:document.getElementById('" + sectionProperties.get(position - mRightDrawerList.getHeaderViewsCount()).sectionId+ "').scrollIntoView();");
mRightDrawerLayout.closeDrawers();
}
});
final ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mLeftDrawerLayout, toolbar, final ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mLeftDrawerLayout, toolbar,
0, 0){ 0, 0){
@ -1178,7 +1185,7 @@ public class KiwixMobileActivity extends AppCompatActivity
String zimArticles = settings.getString(TAG_CURRENT_ARTICLES, null); String zimArticles = settings.getString(TAG_CURRENT_ARTICLES, null);
String zimPositions = settings.getString(TAG_CURRENT_POSITIONS, null); String zimPositions = settings.getString(TAG_CURRENT_POSITIONS, null);
int currentTab = settings.getInt(TAG_CURRENT_TAB, 0 ); int currentTab = settings.getInt(TAG_CURRENT_TAB, 0 );
openZimFile( new File(zimFile), false); openZimFile(new File(zimFile), false);
try { try {
JSONArray urls = new JSONArray(zimArticles); JSONArray urls = new JSONArray(zimArticles);
JSONArray positions = new JSONArray(zimPositions); JSONArray positions = new JSONArray(zimPositions);
@ -1523,14 +1530,6 @@ public class KiwixMobileActivity extends AppCompatActivity
holder = (ViewHolder) row.getTag(); holder = (ViewHolder) row.getTag();
} }
holder.txtTitle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getCurrentWebView().loadUrl("javascript:document.getElementById('" + sectionProperties.get(position).sectionId + "').scrollIntoView();");
mRightDrawerLayout.closeDrawers();
}
});
if (sectionProperties.isEmpty()) if (sectionProperties.isEmpty())
return row; return row;
SectionProperties section = sectionProperties.get(position); SectionProperties section = sectionProperties.get(position);