[Android] Add about window

This commit is contained in:
zilmar 2016-07-08 22:43:51 +10:00
parent 5059e98fb3
commit 8fc2b13190
17 changed files with 397 additions and 22 deletions

View File

@ -74,6 +74,8 @@
android:name="android.app.lib_name" android:name="android.app.lib_name"
android:value="xperia-touchpad" /> android:value="xperia-touchpad" />
</activity> </activity>
<activity
android:name="emu.project64.AboutActivity"
android:theme="@style/Theme.Project64.About" />
</application> </application>
</manifest> </manifest>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/background_actionbar"
android:theme="@style/Project64.Toolbar" />
<android.support.design.widget.TabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/background_actionbar"
app:tabMode="scrollable"
app:tabSelectedTextColor="?attr/font_actionbar_selected"
app:tabTextColor="?attr/font_actionbar"
app:tabIndicatorColor="?attr/font_actionbar_selected"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/about_main" />
<include layout="@layout/about_licence" />
</android.support.v4.view.ViewPager>
</LinearLayout>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</merge>

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/about_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="15dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="15dp" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/logo"
android:layout_width="50dp"
android:layout_height="50dp"
android:contentDescription="@string/info"
android:focusable="false"
android:clickable="false"
android:src="@drawable/icon" />
<TextView
android:textSize="29sp"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/logo"
android:layout_centerVertical="true"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name_full"
android:onClick="onAppNameClick"
android:clickable="true"
/>
</RelativeLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="@string/about_text"
android:textSize="16sp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:layout_weight="0.12"
android:gravity="center|top"
android:text="@string/about_copyright"
android:textSize="14sp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="@string/authors"
android:textSize="12sp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/Project64_authors"
android:textSize="12sp" />
<TextView
android:id="@+id/main_link"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_weight="0.27"
android:autoLink="web"
android:gravity="center"
android:text="@string/about_link"
android:textSize="14sp" />
</LinearLayout>
</ScrollView>

View File

@ -47,6 +47,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize" android:layout_marginTop="?attr/actionBarSize"
android:background="?attr/background_gallerymenu"
/> />
</RelativeLayout> </RelativeLayout>

View File

@ -34,6 +34,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?attr/textMenuColor"
android:textIsSelectable="false" /> android:textIsSelectable="false" />
<TextView <TextView

View File

@ -0,0 +1,8 @@
<android.support.design.widget.TabLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
/>

View File

@ -1,27 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:project64="http://schemas.android.com/apk/res-auto" > xmlns:project64="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/menuItem_library"
android:icon="@drawable/ic_controller"
android:title="@string/categoryLibrary_title"/>
<item <item
android:id="@+id/menuItem_settings" android:id="@+id/menuItem_settings"
android:icon="@drawable/ic_settings" android:icon="@drawable/ic_settings"
android:title="@string/menuItem_settings"/> android:title="@string/menuItem_settings"/>
<item
android:id="@+id/menuItem_forum"
android:icon="@drawable/ic_about"
android:title="@string/menuItem_forum" />
<item <item
android:id="@+id/menuItem_about" android:id="@+id/menuItem_about"
android:icon="@drawable/ic_about" android:icon="@drawable/ic_about"
android:title="@string/menuItem_about"> android:title="@string/menuItem_about" />
<menu>
<item
android:id="@+id/menuItem_appVersion"
android:title="@string/menuItem_appVersion"/>
<item
android:id="@+id/menuItem_hardwareInfo"
android:title="@string/menuItem_hardwareInfo"/>
</menu>
</item>
</menu> </menu>

View File

@ -29,6 +29,7 @@
<string name="menuItem_about">About</string> <string name="menuItem_about">About</string>
<string name="menuItem_appVersion">App version</string> <string name="menuItem_appVersion">App version</string>
<string name="menuItem_hardwareInfo">Hardware info</string> <string name="menuItem_hardwareInfo">Hardware info</string>
<string name="menuItem_forum">Help/Forum</string>
<!-- ************************************************************************** --> <!-- ************************************************************************** -->
<!-- Toast Messages --> <!-- Toast Messages -->
@ -48,6 +49,18 @@
<string name="categoryAudio_title">Audio</string> <string name="categoryAudio_title">Audio</string>
<string name="categoryData_title">Data</string> <string name="categoryData_title">Data</string>
<!-- About -->
<string name="info">Information</string>
<string name="app_name_full">Project64 for Android</string>
<string name="licence">License</string>
<string name="revision">Revision</string>
<string name="about">About</string>
<string name="about_text">Project64 for Android™ is a port of the windows version of project64. The Android™ version can play most N64 games.</string>
<string name="Project64_authors">Project64 Authors.</string>
<string name="about_link" translatable="false"> &lt;a href=&quot;www.pj64-emu.com&quot;&gt;www.pj64-emu.com&lt;/a&gt;</string>
<string name="about_copyright" translatable="false">Copyleft &#169; 1998&#8211;2016 by Project64.\n</string>
<string name="authors" translatable="false">Zilmar, Jabo, Smiff, Gent, Jahra!n, Witten, RadeonUser, Trotterwatch, pixi, Azimer, Gonetz, cxd4, AmbientMalice, LegendOfDragoon, Nekokabu, Lithium64, death-droid, LuigiBlood, dsx.</string>
<!-- Gallery sections --> <!-- Gallery sections -->
<string name="galleryRecentlyPlayed">Recently played</string> <string name="galleryRecentlyPlayed">Recently played</string>
<string name="galleryLibrary">Library</string> <string name="galleryLibrary">Library</string>

View File

@ -0,0 +1,96 @@
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
package emu.project64;
import java.util.Arrays;
import java.util.List;
import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID;
import emu.project64.util.Utility;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;
import android.widget.Toast;
public class AboutActivity extends AppCompatActivity
{
public final static int MODE_ABOUT = 0;
public final static int MODE_LICENCE = 1;
public final static int MODE_TOTAL = 2; // Number of about pages
private int m_title_clicks = 0;
@Override
public void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.about_activity );
// Add the tool bar to the activity (which supports the fancy menu/arrow animation)
Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar );
toolbar.setTitle( getString(R.string.app_name) + " " + NativeExports.appVersion() );
setSupportActionBar( toolbar );
ActionBar actionbar = getSupportActionBar();
if (AndroidDevice.IS_ICE_CREAM_SANDWICH)
{
actionbar.setHomeButtonEnabled(true);
actionbar.setDisplayHomeAsUpEnabled(true);
}
View aboutMain = findViewById(R.id.about_main);
WebView webView = (WebView)findViewById(R.id.webview);
List<View> lists = Arrays.asList(aboutMain, webView);
String[] titles = new String[] {getString(R.string.about), getString(R.string.licence)};
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setOffscreenPageLimit(MODE_TOTAL-1);
viewPager.setAdapter(new AboutPagerAdapter(lists, titles));
TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
tabLayout.setupWithViewPager(viewPager);
TextView link = (TextView)findViewById(R.id.main_link);
link.setText(Html.fromHtml(getString(R.string.about_link)));
webView.loadData(Utility.readAsset("licence.htm", ""), "text/html", "UTF8");
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
public void onAppNameClick(View v)
{
m_title_clicks += 1;
if (m_title_clicks == 6)
{
NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.getValue(), false);
Toast.makeText(this, "Advanced Mode Enabled", Toast.LENGTH_SHORT).show();
}
}
}

View File

@ -0,0 +1,79 @@
/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
package emu.project64;
import android.database.DataSetObserver;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
public class AboutPagerAdapter extends PagerAdapter
{
private List<View> mLists;
private String[] mTitles;
public AboutPagerAdapter(List<View> lists, String[] titles)
{
mLists = lists;
mTitles = titles;
}
@Override
public int getCount()
{
return mLists == null ? 0 : mLists.size();
}
@Override
public boolean isViewFromObject(View view, Object object)
{
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position)
{
View page = mLists.get(position);
container.addView(page);
return page;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object)
{
container.removeView((View) object);
mLists.remove(position);
}
@Override
public CharSequence getPageTitle(int position)
{
if (position < 0 || position >= mTitles.length)
{
return "";
}
else
{
return mTitles[position];
}
}
@Override
public void unregisterDataSetObserver(DataSetObserver observer)
{
if (observer != null)
{
super.unregisterDataSetObserver(observer);
}
}
}

View File

@ -318,8 +318,9 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
Intent GlobalPrefsIntent = new Intent( this, GlobalPrefsActivity.class ); Intent GlobalPrefsIntent = new Intent( this, GlobalPrefsActivity.class );
startActivity( GlobalPrefsIntent ); startActivity( GlobalPrefsIntent );
return true; return true;
case R.id.menuItem_hardwareInfo: case R.id.menuItem_about:
Popups.showHardwareInfo( this ); Intent AboutIntent = new Intent(this, AboutActivity.class);
startActivity( AboutIntent );
return true; return true;
default: default:
return super.onOptionsItemSelected( item ); return super.onOptionsItemSelected( item );

View File

@ -11,6 +11,7 @@
package emu.project64; package emu.project64;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
public class Project64Application extends android.app.Application public class Project64Application extends android.app.Application
{ {
@ -31,4 +32,12 @@ public class Project64Application extends android.app.Application
{ {
return m_instance; return m_instance;
} }
/**
* @return the main resources from the Application
*/
public static Resources getAppResources()
{
return m_instance.getResources();
}
} }

View File

@ -21,6 +21,7 @@ public class NativeExports
} }
public static native void appInit (String BaseDir ); public static native void appInit (String BaseDir );
public static native String appVersion();
public static native void StopEmulation(); public static native void StopEmulation();
public static native void StartEmulation(); public static native void StartEmulation();
public static native void CloseSystem(); public static native void CloseSystem();

View File

@ -13,7 +13,10 @@ package emu.project64.util;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import emu.project64.Project64Application;
/** /**
* Utility class which collects a bunch of commonly used methods into one class. * Utility class which collects a bunch of commonly used methods into one class.
*/ */
@ -82,4 +85,38 @@ public final class Utility
} }
return false; return false;
} }
public static String readAsset(String assetName, String defaultS)
{
InputStream is = null;
BufferedReader r = null;
try
{
is = Project64Application.getAppResources().getAssets().open(assetName);
r = new BufferedReader(new InputStreamReader(is, "UTF8"));
StringBuilder sb = new StringBuilder();
String line = r.readLine();
if(line != null)
{
sb.append(line);
line = r.readLine();
while(line != null)
{
sb.append('\n');
sb.append(line);
line = r.readLine();
}
}
return sb.toString();
}
catch (IOException e)
{
return defaultS;
}
finally
{
close(is);
close(r);
}
}
} }

View File

@ -131,6 +131,11 @@ EXPORT jboolean CALL Java_emu_project64_jni_NativeExports_appInit(JNIEnv* env, j
return res; return res;
} }
EXPORT jstring CALL Java_emu_project64_jni_NativeExports_appVersion(JNIEnv* env, jclass cls)
{
return env->NewStringUTF(VER_FILE_VERSION_STR);
}
EXPORT void CALL Java_emu_project64_jni_NativeExports_SettingsSaveBool(JNIEnv* env, jclass cls, int Type, jboolean Value) EXPORT void CALL Java_emu_project64_jni_NativeExports_SettingsSaveBool(JNIEnv* env, jclass cls, int Type, jboolean Value)
{ {
WriteTrace(TraceUserInterface, TraceDebug, "Saving %d value: %s",Type,Value ? "true" : "false"); WriteTrace(TraceUserInterface, TraceDebug, "Saving %d value: %s",Type,Value ? "true" : "false");