Revision 9f5bcd3f
.gitignore | ||
---|---|---|
12 | 12 |
|
13 | 13 |
# products of "android create project" or "android update project" |
14 | 14 |
build.xml |
15 |
ant.properties |
|
16 |
default.properties |
|
15 | 17 |
local.properties |
16 | 18 |
proguard-project.txt |
17 | 19 |
proguard.cfg |
20 |
proguard-rules.pro |
|
18 | 21 |
|
19 | 22 |
# emacs detritus |
20 | 23 |
*~ |
... | ... | |
24 | 27 |
|
25 | 28 |
# Mac OS X detritus |
26 | 29 |
.DS_Store |
30 |
|
|
31 |
# Windows thumbnail db |
|
32 |
Thumbs.db |
|
33 |
|
|
34 |
# Android Studio |
|
35 |
*.iml |
|
36 |
.idea/ |
|
37 |
.gradle/ |
|
38 |
build/ |
|
39 |
gradle.properties |
app/build.gradle | ||
---|---|---|
1 |
apply plugin: 'com.android.application' |
|
2 |
|
|
3 |
android { |
|
4 |
compileSdkVersion 23 |
|
5 |
buildToolsVersion "23.0.2" |
|
6 |
|
|
7 |
defaultConfig { |
|
8 |
applicationId "info.guardianproject.trustedintents" |
|
9 |
minSdkVersion 7 |
|
10 |
targetSdkVersion 23 |
|
11 |
versionCode 1 |
|
12 |
versionName "1.0" |
|
13 |
} |
|
14 |
buildTypes { |
|
15 |
release { |
|
16 |
minifyEnabled false |
|
17 |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
|
18 |
} |
|
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
dependencies { |
|
23 |
compile fileTree(dir: 'libs', include: ['*.jar']) |
|
24 |
testCompile 'junit:junit:4.12' |
|
25 |
compile 'com.android.support:appcompat-v7:23.1.1' |
|
26 |
compile 'com.android.support:design:23.1.1' |
|
27 |
} |
app/src/androidTest/java/info/guardianproject/trustedintents/ApplicationTest.java | ||
---|---|---|
1 |
package info.guardianproject.trustedintents; |
|
2 |
|
|
3 |
import android.app.Application; |
|
4 |
import android.test.ApplicationTestCase; |
|
5 |
|
|
6 |
/** |
|
7 |
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> |
|
8 |
*/ |
|
9 |
public class ApplicationTest extends ApplicationTestCase<Application> { |
|
10 |
public ApplicationTest() { |
|
11 |
super(Application.class); |
|
12 |
} |
|
13 |
} |
app/src/main/AndroidManifest.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
package="info.guardianproject.trustedintents" > |
|
4 |
|
|
5 |
<application |
|
6 |
android:allowBackup="true" |
|
7 |
android:icon="@mipmap/ic_launcher" |
|
8 |
android:label="@string/app_name" |
|
9 |
android:supportsRtl="true" |
|
10 |
android:theme="@style/AppTheme" > |
|
11 |
<activity |
|
12 |
android:name=".MainActivity" |
|
13 |
android:label="@string/app_name" |
|
14 |
android:theme="@style/AppTheme.NoActionBar" > |
|
15 |
<intent-filter> |
|
16 |
<action android:name="android.intent.action.MAIN" /> |
|
17 |
|
|
18 |
<category android:name="android.intent.category.LAUNCHER" /> |
|
19 |
</intent-filter> |
|
20 |
</activity> |
|
21 |
</application> |
|
22 |
|
|
23 |
</manifest> |
app/src/main/java/info/guardianproject/trustedintents/MainActivity.java | ||
---|---|---|
1 |
package info.guardianproject.trustedintents; |
|
2 |
|
|
3 |
import android.app.Activity; |
|
4 |
import android.content.ActivityNotFoundException; |
|
5 |
import android.content.Intent; |
|
6 |
import android.os.Bundle; |
|
7 |
import android.support.design.widget.FloatingActionButton; |
|
8 |
import android.support.design.widget.Snackbar; |
|
9 |
import android.support.v7.app.AppCompatActivity; |
|
10 |
import android.support.v7.widget.Toolbar; |
|
11 |
import android.view.Menu; |
|
12 |
import android.view.MenuItem; |
|
13 |
import android.view.View; |
|
14 |
import android.widget.Toast; |
|
15 |
|
|
16 |
import org.torproject.TorProjectRSA1024; |
|
17 |
|
|
18 |
import java.security.cert.CertificateException; |
|
19 |
|
|
20 |
import info.guardianproject.GuardianProjectRSA1024; |
|
21 |
|
|
22 |
public class MainActivity extends AppCompatActivity { |
|
23 |
|
|
24 |
private static TrustedIntents trustedIntents; |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void onCreate(Bundle savedInstanceState) { |
|
28 |
super.onCreate(savedInstanceState); |
|
29 |
|
|
30 |
trustedIntents = TrustedIntents.get(this); |
|
31 |
trustedIntents.addTrustedSigner(GuardianProjectRSA1024.class); |
|
32 |
|
|
33 |
setContentView(R.layout.activity_main); |
|
34 |
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); |
|
35 |
setSupportActionBar(toolbar); |
|
36 |
|
|
37 |
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); |
|
38 |
fab.setOnClickListener(new View.OnClickListener() { |
|
39 |
@Override |
|
40 |
public void onClick(View view) { |
|
41 |
final Activity activity = MainActivity.this; |
|
42 |
try { |
|
43 |
Intent intent = new Intent(Intent.ACTION_VIEW); |
|
44 |
intent.setClassName("info.guardianproject.gpg", |
|
45 |
"info.guardianproject.gpg.MainActivity"); |
|
46 |
trustedIntents.startActivity(activity, intent); |
|
47 |
} catch (ActivityNotFoundException e) { |
|
48 |
e.printStackTrace(); |
|
49 |
Toast.makeText(activity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); |
|
50 |
} catch (CertificateException e) { |
|
51 |
e.printStackTrace(); |
|
52 |
Toast.makeText(activity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); |
|
53 |
} |
|
54 |
} |
|
55 |
}); |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public boolean onCreateOptionsMenu(Menu menu) { |
|
60 |
// Inflate the menu; this adds items to the action bar if it is present. |
|
61 |
getMenuInflater().inflate(R.menu.menu_main, menu); |
|
62 |
return true; |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
public boolean onOptionsItemSelected(MenuItem item) { |
|
67 |
// Handle action bar item clicks here. The action bar will |
|
68 |
// automatically handle clicks on the Home/Up button, so long |
|
69 |
// as you specify a parent activity in AndroidManifest.xml. |
|
70 |
int id = item.getItemId(); |
|
71 |
|
|
72 |
//noinspection SimplifiableIfStatement |
|
73 |
if (id == R.id.action_settings) { |
|
74 |
return true; |
|
75 |
} |
|
76 |
|
|
77 |
return super.onOptionsItemSelected(item); |
|
78 |
} |
|
79 |
} |
app/src/main/res/layout/activity_main.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<android.support.design.widget.CoordinatorLayout |
|
3 |
xmlns:android="http://schemas.android.com/apk/res/android" |
|
4 |
xmlns:app="http://schemas.android.com/apk/res-auto" |
|
5 |
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" |
|
6 |
android:layout_height="match_parent" android:fitsSystemWindows="true" |
|
7 |
tools:context=".MainActivity"> |
|
8 |
|
|
9 |
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content" |
|
10 |
android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay"> |
|
11 |
|
|
12 |
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" |
|
13 |
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" |
|
14 |
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> |
|
15 |
|
|
16 |
</android.support.design.widget.AppBarLayout> |
|
17 |
|
|
18 |
<include layout="@layout/content_main" /> |
|
19 |
|
|
20 |
<android.support.design.widget.FloatingActionButton android:id="@+id/fab" |
|
21 |
android:layout_width="wrap_content" android:layout_height="wrap_content" |
|
22 |
android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" |
|
23 |
android:src="@android:drawable/ic_dialog_email" /> |
|
24 |
|
|
25 |
</android.support.design.widget.CoordinatorLayout> |
app/src/main/res/layout/content_main.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
3 |
xmlns:tools="http://schemas.android.com/tools" |
|
4 |
xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" |
|
5 |
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" |
|
6 |
android:paddingRight="@dimen/activity_horizontal_margin" |
|
7 |
android:paddingTop="@dimen/activity_vertical_margin" |
|
8 |
android:paddingBottom="@dimen/activity_vertical_margin" |
|
9 |
app:layout_behavior="@string/appbar_scrolling_view_behavior" |
|
10 |
tools:showIn="@layout/activity_main" tools:context=".MainActivity"> |
|
11 |
|
|
12 |
<TextView android:text="Hello World!" android:layout_width="wrap_content" |
|
13 |
android:layout_height="wrap_content" /> |
|
14 |
</RelativeLayout> |
app/src/main/res/menu/menu_main.xml | ||
---|---|---|
1 |
<menu xmlns:android="http://schemas.android.com/apk/res/android" |
|
2 |
xmlns:app="http://schemas.android.com/apk/res-auto" |
|
3 |
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"> |
|
4 |
<item android:id="@+id/action_settings" android:title="@string/action_settings" |
|
5 |
android:orderInCategory="100" app:showAsAction="never" /> |
|
6 |
</menu> |
app/src/main/res/values-v21/styles.xml | ||
---|---|---|
1 |
<resources>> |
|
2 |
<style name="AppTheme.NoActionBar"> |
|
3 |
<item name="windowActionBar">false</item> |
|
4 |
<item name="windowNoTitle">true</item> |
|
5 |
<item name="android:windowDrawsSystemBarBackgrounds">true</item> |
|
6 |
<item name="android:statusBarColor">@android:color/transparent</item> |
|
7 |
</style> |
|
8 |
</resources> |
app/src/main/res/values-w820dp/dimens.xml | ||
---|---|---|
1 |
<resources> |
|
2 |
<!-- Example customization of dimensions originally defined in res/values/dimens.xml |
|
3 |
(such as screen margins) for screens with more than 820dp of available width. This |
|
4 |
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> |
|
5 |
<dimen name="activity_horizontal_margin">64dp</dimen> |
|
6 |
</resources> |
app/src/main/res/values/colors.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="utf-8"?> |
|
2 |
<resources> |
|
3 |
<color name="colorPrimary">#3F51B5</color> |
|
4 |
<color name="colorPrimaryDark">#303F9F</color> |
|
5 |
<color name="colorAccent">#FF4081</color> |
|
6 |
</resources> |
app/src/main/res/values/dimens.xml | ||
---|---|---|
1 |
<resources> |
|
2 |
<!-- Default screen margins, per the Android Design guidelines. --> |
|
3 |
<dimen name="activity_horizontal_margin">16dp</dimen> |
|
4 |
<dimen name="activity_vertical_margin">16dp</dimen> |
|
5 |
<dimen name="fab_margin">16dp</dimen> |
|
6 |
</resources> |
app/src/main/res/values/strings.xml | ||
---|---|---|
1 |
<resources> |
|
2 |
<string name="app_name">TrustedIntents</string> |
|
3 |
<string name="action_settings">Settings</string> |
|
4 |
</resources> |
app/src/main/res/values/styles.xml | ||
---|---|---|
1 |
<resources> |
|
2 |
|
|
3 |
<!-- Base application theme. --> |
|
4 |
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> |
|
5 |
<!-- Customize your theme here. --> |
|
6 |
<item name="colorPrimary">@color/colorPrimary</item> |
|
7 |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> |
|
8 |
<item name="colorAccent">@color/colorAccent</item> |
|
9 |
</style> |
|
10 |
<style name="AppTheme.NoActionBar"> |
|
11 |
<item name="windowActionBar">false</item> |
|
12 |
<item name="windowNoTitle">true</item> |
|
13 |
</style> |
|
14 |
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> |
|
15 |
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> |
|
16 |
|
|
17 |
</resources> |
app/src/test/java/info/guardianproject/trustedintents/ExampleUnitTest.java | ||
---|---|---|
1 |
package info.guardianproject.trustedintents; |
|
2 |
|
|
3 |
import org.junit.Test; |
|
4 |
|
|
5 |
import static org.junit.Assert.*; |
|
6 |
|
|
7 |
/** |
|
8 |
* To work on unit tests, switch the Test Artifact in the Build Variants view. |
|
9 |
*/ |
|
10 |
public class ExampleUnitTest { |
|
11 |
@Test |
|
12 |
public void addition_isCorrect() throws Exception { |
|
13 |
assertEquals(4, 2 + 2); |
|
14 |
} |
|
15 |
} |
build.gradle | ||
---|---|---|
1 |
buildscript { |
|
2 |
repositories { |
|
3 |
jcenter() |
|
4 |
} |
|
5 |
dependencies { |
|
6 |
classpath 'com.android.tools.build:gradle:1.+' |
|
7 |
} |
|
8 |
} |
|
9 |
|
|
10 |
allprojects { |
|
11 |
repositories { |
|
12 |
jcenter() |
|
13 |
} |
|
14 |
} |
|
15 |
|
|
16 |
task clean(type: Delete) { |
|
17 |
delete rootProject.buildDir |
|
18 |
} |
settings.gradle | ||
---|---|---|
1 |
include ':app' |
Also available in: Unified diff