Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back standalone app to life #199

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
111 changes: 111 additions & 0 deletions app/build.gradle
@@ -0,0 +1,111 @@
/*
* SPDX-FileCopyrightText: 2019, microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/


apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
apply plugin: 'signing'

String getMyVersionName() {
def stdout = new ByteArrayOutputStream()
if (rootProject.file("gradlew").exists())
exec { commandLine 'git', 'describe', '--tags', '--always', '--dirty'; standardOutput = stdout }
else // automatic build system, don't tag dirty
exec { commandLine 'git', 'describe', '--tags', '--always'; standardOutput = stdout }
return stdout.toString().trim().substring(1)
}

int getMyVersionCode() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--count', "HEAD"
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
}

android {
compileSdkVersion androidCompileSdk
buildToolsVersion "$androidBuildVersionTools"
dataBinding {
enabled = true
}

defaultConfig {
versionName getMyVersionName()
versionCode(20000 + getMyVersionCode())
minSdkVersion Math.max(androidMinSdk, 14)
targetSdkVersion androidTargetSdk
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

flavorDimensions 'default'
productFlavors {
NetworkLocation {
applicationId = 'com.google.android.gms'
minSdkVersion 19
dimension 'default'
}
LegacyNetworkLocation {
applicationId = 'com.google.android.location'
dimension 'default'
}
UnifiedNlp {
applicationId = 'org.microg.nlp'
dimension 'default'
}
}

compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

kotlinOptions {
jvmTarget = "1.8"
}

lintOptions {
warning "MissingTranslation"
}
}

apply from: "../gradle/androidJars.gradle"

dependencies {
implementation project(':api')
implementation project(':geocode-v1')
implementation project(':location-v2')
implementation project(':location-v3')
implementation project(':service')
api project(':client')
api project(':ui')

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

// AndroidX UI
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "androidx.preference:preference:$preferenceVersion"
implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion"

// Navigation
implementation "androidx.navigation:navigation-fragment:$navigationVersion"
implementation "androidx.navigation:navigation-ui:$navigationVersion"
implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion"
implementation "androidx.navigation:navigation-ui-ktx:$navigationVersion"
}

afterEvaluate {
android.applicationVariants.all { variant ->
variant.resValue 'string', 'application_id', variant.applicationId
}
}
54 changes: 54 additions & 0 deletions app/src/main/AndroidManifest.xml
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2013-2017 microG Project Team
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.microg.nlp.app">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_nlp_app"
android:label="@string/nlp_app_name"
android:theme="@style/Theme.AppCompat.DayNight">

<activity
android:name="org.microg.nlp.ui.BackendSettingsActivity"
android:process=":ui" />

<activity
android:name="org.microg.nlp.app.SettingsActivity"
android:icon="@mipmap/ic_nlp_settings"
android:label="@string/nlp_app_name"
android:process=":ui">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name="org.microg.nlp.app.SelfCheckFragment$AsActivity"
android:label="@string/self_check_title"
android:process=":ui" />

<activity
android:name="org.microg.nlp.app.AboutFragment$AsActivity"
android:label="@string/pref_about_title"
android:process=":ui" />
</application>
</manifest>
45 changes: 45 additions & 0 deletions app/src/main/java/org/microg/nlp/app/AboutFragment.java
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2013-2017 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.microg.nlp.app;

import androidx.fragment.app.Fragment;

import org.microg.nlp.app.BuildConfig;

import org.microg.nlp.app.tools.ui.AbstractAboutFragment;
import org.microg.nlp.app.tools.ui.AbstractSettingsActivity;

import java.util.List;

public class AboutFragment extends AbstractAboutFragment {

@Override
protected void collectLibraries(List<AbstractAboutFragment.Library> libraries) {
libraries.add(new AbstractAboutFragment.Library("org.microg.nlp.service", "UnifiedNlp", "Apache License 2.0, microG Team"));
}

public static class AsActivity extends AbstractSettingsActivity {
public AsActivity() {
showHomeAsUp = true;
}

@Override
protected Fragment getFragment() {
return new AboutFragment();
}
}
}
22 changes: 22 additions & 0 deletions app/src/main/java/org/microg/nlp/app/LocationSettingsActivity.java
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2013-2017 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.microg.nlp.app;

import android.app.Activity;

public class LocationSettingsActivity extends Activity {
}
79 changes: 79 additions & 0 deletions app/src/main/java/org/microg/nlp/app/SelfCheckFragment.java
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2013-2017 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.microg.nlp.app;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import org.microg.nlp.app.tools.selfcheck.PermissionCheckGroup;
import org.microg.nlp.app.tools.selfcheck.SelfCheckGroup;
import org.microg.nlp.app.tools.ui.AbstractSelfCheckFragment;
import org.microg.nlp.app.tools.ui.AbstractSettingsActivity;
import org.microg.nlp.app.tools.selfcheck.NlpOsCompatChecks;
import org.microg.nlp.app.tools.selfcheck.NlpStatusChecks;

import java.util.ArrayList;
import java.util.List;

import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.os.Build.VERSION.SDK_INT;
import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1;

public class SelfCheckFragment extends AbstractSelfCheckFragment {

@Override
protected void prepareSelfCheckList(List<SelfCheckGroup> checks) {
if (SDK_INT > LOLLIPOP_MR1) {
checks.add(new PermissionCheckGroup(ACCESS_COARSE_LOCATION));
}
checks.add(new NlpOsCompatChecks());
checks.add(new NlpStatusChecks());
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
reset(LayoutInflater.from(getContext()));
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
reset(LayoutInflater.from(getContext()));
super.onActivityResult(requestCode, resultCode, data);
}

public static class AsActivity extends AbstractSettingsActivity {
public AsActivity() {
showHomeAsUp = true;
}

@Override
protected Fragment getFragment() {
return new SelfCheckFragment();
}
}
}
34 changes: 34 additions & 0 deletions app/src/main/java/org/microg/nlp/app/SettingsActivity.java
@@ -0,0 +1,34 @@
package org.microg.nlp.app;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

public class SettingsActivity extends AppCompatActivity {
private AppBarConfiguration appBarConfiguration;

private NavController getNavController() {
return ((NavHostFragment)getSupportFragmentManager().findFragmentById(R.id.navhost)).getNavController();
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.settings_root_activity);

appBarConfiguration = new AppBarConfiguration.Builder(getNavController().getGraph()).build();
NavigationUI.setupActionBarWithNavController(this, getNavController(), appBarConfiguration);
}

@Override
public boolean onSupportNavigateUp() {
return NavigationUI.navigateUp(getNavController(), appBarConfiguration) || super.onSupportNavigateUp();
}
}