Skip to content

Commit 4e3c71b

Browse files
committed
Add back standalone app
1 parent 7adcb77 commit 4e3c71b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2275
-1
lines changed

app/build.gradle

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2019, microG Project Team
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
7+
apply plugin: 'com.android.application'
8+
apply plugin: 'kotlin-android'
9+
apply plugin: 'kotlin-kapt'
10+
apply plugin: 'kotlin-android-extensions'
11+
apply plugin: 'maven-publish'
12+
apply plugin: 'signing'
13+
14+
String getMyVersionName() {
15+
def stdout = new ByteArrayOutputStream()
16+
if (rootProject.file("gradlew").exists())
17+
exec { commandLine 'git', 'describe', '--tags', '--always', '--dirty'; standardOutput = stdout }
18+
else // automatic build system, don't tag dirty
19+
exec { commandLine 'git', 'describe', '--tags', '--always'; standardOutput = stdout }
20+
return stdout.toString().trim().substring(1)
21+
}
22+
23+
int getMyVersionCode() {
24+
def stdout = new ByteArrayOutputStream()
25+
exec {
26+
commandLine 'git', 'rev-list', '--count', "HEAD"
27+
standardOutput = stdout
28+
}
29+
return Integer.parseInt(stdout.toString().trim())
30+
}
31+
32+
android {
33+
compileSdkVersion androidCompileSdk
34+
buildToolsVersion "$androidBuildVersionTools"
35+
dataBinding {
36+
enabled = true
37+
}
38+
39+
defaultConfig {
40+
versionName getMyVersionName()
41+
versionCode(20000 + getMyVersionCode())
42+
minSdkVersion Math.max(androidMinSdk, 14)
43+
targetSdkVersion androidTargetSdk
44+
}
45+
46+
sourceSets {
47+
main.java.srcDirs += 'src/main/kotlin'
48+
}
49+
50+
flavorDimensions 'default'
51+
productFlavors {
52+
NetworkLocation {
53+
applicationId = 'com.google.android.gms'
54+
minSdkVersion 19
55+
dimension 'default'
56+
}
57+
LegacyNetworkLocation {
58+
applicationId = 'com.google.android.location'
59+
dimension 'default'
60+
}
61+
UnifiedNlp {
62+
applicationId = 'org.microg.nlp'
63+
dimension 'default'
64+
}
65+
}
66+
67+
compileOptions {
68+
sourceCompatibility = 1.8
69+
targetCompatibility = 1.8
70+
}
71+
72+
kotlinOptions {
73+
jvmTarget = "1.8"
74+
}
75+
76+
lintOptions {
77+
warning "MissingTranslation"
78+
}
79+
}
80+
81+
apply from: "../gradle/androidJars.gradle"
82+
83+
dependencies {
84+
implementation project(':api')
85+
implementation project(':geocode-v1')
86+
implementation project(':location-v2')
87+
implementation project(':location-v3')
88+
implementation project(':service')
89+
api project(':client')
90+
api project(':ui')
91+
92+
// Kotlin
93+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
94+
95+
// AndroidX UI
96+
implementation "androidx.appcompat:appcompat:$appcompatVersion"
97+
implementation "androidx.preference:preference:$preferenceVersion"
98+
implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion"
99+
100+
// Navigation
101+
implementation "androidx.navigation:navigation-fragment:$navigationVersion"
102+
implementation "androidx.navigation:navigation-ui:$navigationVersion"
103+
implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion"
104+
implementation "androidx.navigation:navigation-ui-ktx:$navigationVersion"
105+
}
106+
107+
afterEvaluate {
108+
android.applicationVariants.all { variant ->
109+
variant.resValue 'string', 'application_id', variant.applicationId
110+
}
111+
}

app/src/main/AndroidManifest.xml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (C) 2013-2017 microG Project Team
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:tools="http://schemas.android.com/tools"
19+
package="org.microg.nlp.app">
20+
21+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
22+
23+
<application
24+
android:allowBackup="true"
25+
android:icon="@mipmap/ic_nlp_app"
26+
android:label="@string/nlp_app_name"
27+
android:theme="@style/Theme.AppCompat.DayNight">
28+
29+
<activity
30+
android:name="org.microg.nlp.ui.BackendSettingsActivity"
31+
android:process=":ui" />
32+
33+
<activity
34+
android:name="org.microg.nlp.app.SettingsActivity"
35+
android:icon="@mipmap/ic_nlp_settings"
36+
android:label="@string/nlp_app_name"
37+
android:process=":ui">
38+
<intent-filter>
39+
<action android:name="android.intent.action.MAIN" />
40+
<category android:name="android.intent.category.LAUNCHER" />
41+
</intent-filter>
42+
</activity>
43+
44+
<activity
45+
android:name="org.microg.nlp.app.SelfCheckFragment$AsActivity"
46+
android:label="@string/self_check_title"
47+
android:process=":ui" />
48+
49+
<activity
50+
android:name="org.microg.nlp.app.AboutFragment$AsActivity"
51+
android:label="@string/pref_about_title"
52+
android:process=":ui" />
53+
</application>
54+
</manifest>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2013-2017 microG Project Team
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.microg.nlp.app;
18+
19+
import androidx.fragment.app.Fragment;
20+
21+
import org.microg.nlp.app.BuildConfig;
22+
23+
import org.microg.nlp.app.tools.ui.AbstractAboutFragment;
24+
import org.microg.nlp.app.tools.ui.AbstractSettingsActivity;
25+
26+
import java.util.List;
27+
28+
public class AboutFragment extends AbstractAboutFragment {
29+
30+
@Override
31+
protected void collectLibraries(List<AbstractAboutFragment.Library> libraries) {
32+
libraries.add(new AbstractAboutFragment.Library("org.microg.nlp.service", "UnifiedNlp", "Apache License 2.0, microG Team"));
33+
}
34+
35+
public static class AsActivity extends AbstractSettingsActivity {
36+
public AsActivity() {
37+
showHomeAsUp = true;
38+
}
39+
40+
@Override
41+
protected Fragment getFragment() {
42+
return new AboutFragment();
43+
}
44+
}
45+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (C) 2013-2017 microG Project Team
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.microg.nlp.app;
18+
19+
import android.app.Activity;
20+
21+
public class LocationSettingsActivity extends Activity {
22+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (C) 2013-2017 microG Project Team
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.microg.nlp.app;
18+
19+
import android.content.Context;
20+
import android.content.Intent;
21+
import android.content.pm.PackageManager;
22+
import android.content.pm.PermissionGroupInfo;
23+
import android.content.pm.PermissionInfo;
24+
import android.net.Uri;
25+
import android.os.Build;
26+
import android.provider.Settings;
27+
import android.util.Log;
28+
import android.view.LayoutInflater;
29+
30+
import androidx.annotation.NonNull;
31+
import androidx.fragment.app.Fragment;
32+
33+
import org.microg.nlp.app.tools.selfcheck.PermissionCheckGroup;
34+
import org.microg.nlp.app.tools.selfcheck.SelfCheckGroup;
35+
import org.microg.nlp.app.tools.ui.AbstractSelfCheckFragment;
36+
import org.microg.nlp.app.tools.ui.AbstractSettingsActivity;
37+
import org.microg.nlp.app.tools.selfcheck.NlpOsCompatChecks;
38+
import org.microg.nlp.app.tools.selfcheck.NlpStatusChecks;
39+
40+
import java.util.ArrayList;
41+
import java.util.List;
42+
43+
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
44+
import static android.os.Build.VERSION.SDK_INT;
45+
import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1;
46+
47+
public class SelfCheckFragment extends AbstractSelfCheckFragment {
48+
49+
@Override
50+
protected void prepareSelfCheckList(List<SelfCheckGroup> checks) {
51+
if (SDK_INT > LOLLIPOP_MR1) {
52+
checks.add(new PermissionCheckGroup(ACCESS_COARSE_LOCATION));
53+
}
54+
checks.add(new NlpOsCompatChecks());
55+
checks.add(new NlpStatusChecks());
56+
}
57+
58+
@Override
59+
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
60+
reset(LayoutInflater.from(getContext()));
61+
}
62+
63+
@Override
64+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
65+
reset(LayoutInflater.from(getContext()));
66+
super.onActivityResult(requestCode, resultCode, data);
67+
}
68+
69+
public static class AsActivity extends AbstractSettingsActivity {
70+
public AsActivity() {
71+
showHomeAsUp = true;
72+
}
73+
74+
@Override
75+
protected Fragment getFragment() {
76+
return new SelfCheckFragment();
77+
}
78+
}
79+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.microg.nlp.app;
2+
3+
import android.content.Intent;
4+
import android.os.Bundle;
5+
6+
import androidx.annotation.Nullable;
7+
import androidx.appcompat.app.AppCompatActivity;
8+
import androidx.navigation.NavController;
9+
import androidx.navigation.fragment.NavHostFragment;
10+
import androidx.navigation.ui.AppBarConfiguration;
11+
import androidx.navigation.ui.NavigationUI;
12+
13+
public class SettingsActivity extends AppCompatActivity {
14+
private AppBarConfiguration appBarConfiguration;
15+
16+
private NavController getNavController() {
17+
return ((NavHostFragment)getSupportFragmentManager().findFragmentById(R.id.navhost)).getNavController();
18+
}
19+
20+
@Override
21+
protected void onCreate(@Nullable Bundle savedInstanceState) {
22+
super.onCreate(savedInstanceState);
23+
24+
setContentView(R.layout.settings_root_activity);
25+
26+
appBarConfiguration = new AppBarConfiguration.Builder(getNavController().getGraph()).build();
27+
NavigationUI.setupActionBarWithNavController(this, getNavController(), appBarConfiguration);
28+
}
29+
30+
@Override
31+
public boolean onSupportNavigateUp() {
32+
return NavigationUI.navigateUp(getNavController(), appBarConfiguration) || super.onSupportNavigateUp();
33+
}
34+
}

0 commit comments

Comments
 (0)