Skip to content

Commit 26edc67

Browse files
committed
Add back standalone app
1 parent 7adcb77 commit 26edc67

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

+2256
-1
lines changed

app/build.gradle

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
android {
15+
compileSdkVersion androidCompileSdk
16+
buildToolsVersion "$androidBuildVersionTools"
17+
dataBinding {
18+
enabled = true
19+
}
20+
21+
defaultConfig {
22+
versionName version
23+
minSdkVersion Math.max(androidMinSdk, 14)
24+
targetSdkVersion androidTargetSdk
25+
}
26+
27+
sourceSets {
28+
main.java.srcDirs += 'src/main/kotlin'
29+
}
30+
31+
flavorDimensions 'default'
32+
productFlavors {
33+
NetworkLocation {
34+
applicationId = 'com.google.android.gms'
35+
minSdkVersion 19
36+
dimension 'default'
37+
}
38+
LegacyNetworkLocation {
39+
applicationId = 'com.google.android.location'
40+
dimension 'default'
41+
}
42+
UnifiedNlp {
43+
applicationId = 'org.microg.nlp'
44+
dimension 'default'
45+
}
46+
}
47+
48+
compileOptions {
49+
sourceCompatibility = 1.8
50+
targetCompatibility = 1.8
51+
}
52+
53+
kotlinOptions {
54+
jvmTarget = "1.8"
55+
}
56+
57+
lintOptions {
58+
warning "MissingTranslation"
59+
}
60+
}
61+
62+
apply from: "../gradle/androidJars.gradle"
63+
64+
dependencies {
65+
implementation project(':api')
66+
implementation project(':geocode-v1')
67+
implementation project(':location-v2')
68+
implementation project(':location-v3')
69+
implementation project(':service')
70+
api project(':client')
71+
api project(':ui')
72+
73+
// Kotlin
74+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
75+
76+
// AndroidX UI
77+
implementation "androidx.appcompat:appcompat:$appcompatVersion"
78+
implementation "androidx.preference:preference:$preferenceVersion"
79+
implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion"
80+
81+
// Navigation
82+
implementation "androidx.navigation:navigation-fragment:$navigationVersion"
83+
implementation "androidx.navigation:navigation-ui:$navigationVersion"
84+
implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion"
85+
implementation "androidx.navigation:navigation-ui-ktx:$navigationVersion"
86+
}
87+
88+
afterEvaluate {
89+
android.applicationVariants.all { variant ->
90+
variant.resValue 'string', 'application_id', variant.applicationId
91+
}
92+
}

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)