Skip to content
This repository has been archived by the owner on Jan 23, 2019. It is now read-only.

some maintenance and code readability #279

Open
wants to merge 6 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions resources/tintcopy-drawable.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python3

import os
# Requires imagemagick's convert
#
# Tints the drawables under 'drawable' by changing their white color
# with the used accent color on the application, and outputs the result
# to the 'drawable' folder used by the application. Run this if you add
# new drawables on the folder. Icons from https://material.io/icons
import re
import os
import subprocess

# http://www.imagemagick.org/Usage/color_mods/#diy_levels
Expand All @@ -34,4 +34,3 @@
ipng = os.path.join('drawable', dpi, png)
opng = os.path.join(outdir, dpi, png.replace('_white', ''))
subprocess.run(command.format(ipng, color, opng), shell=True)

47 changes: 29 additions & 18 deletions src/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@ if (enable_plugin_kotlin) {
apply plugin: 'kotlin-kapt'
}

ext.version_setup_minSdk = 15

android {
compileSdkVersion version_setup_compileSdk
flavorDimensions "default"
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion version_setup_minSdk
targetSdkVersion version_setup_targetSdk

applicationId "io.github.lonamiwebs.stringlate"
minSdkVersion 15
targetSdkVersion 28
versionCode 1006
versionName "0.15.1"
applicationId "io.github.lonamiwebs.stringlate"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand All @@ -27,10 +24,7 @@ android {
resValue "string", "manifest_package_id", "io.github.lonamiwebs.stringlate"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "default"

buildTypes {
release {
Expand All @@ -45,6 +39,12 @@ android {
}
}

compileOptions {
encoding = 'UTF-8'
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
disable 'MissingTranslation'
disable 'ExtraTranslation'
Expand All @@ -58,22 +58,33 @@ android {
}
}

ext {
// https://developer.android.com/topic/libraries/support-library/revisions.html
supportLib = '28.0.0'

// https://github.com/JakeWharton/butterknife/releases
butterknife = '8.8.1'

// https://github.com/guardianproject/NetCipher/releases
netcipher = '2.0.0-beta1'
}

dependencies {
// Android standard libs
implementation "com.android.support:appcompat-v7:${version_library_appcompat}"
implementation "com.android.support:design:${version_library_appcompat}"
implementation "com.android.support:preference-v7:${version_library_appcompat}"
implementation "com.android.support:preference-v14:${version_library_appcompat}"
implementation "com.android.support:design:${supportLib}"
implementation "com.android.support:appcompat-v7:${supportLib}"
implementation "com.android.support:preference-v7:${supportLib}"
implementation "com.android.support:preference-v14:${supportLib}"
// Tool libraries
implementation "com.jakewharton:butterknife:${version_library_butterknife}"
implementation "com.jakewharton:butterknife:${butterknife}"
// Include core project
implementation(project(':core')) {
exclude(group: 'org.json', module: 'json')
exclude(group: 'org.apache.servicemix.bundles', module: 'org.apache.servicemix.bundles.xmlpull')
}

// Processors
def anpros = ["com.jakewharton:butterknife-compiler:${version_library_butterknife}"]
def anpros = ["com.jakewharton:butterknife-compiler:${butterknife}"]
for (anpro in anpros) {
if (enable_plugin_kotlin) {
kapt anpro
Expand Down
20 changes: 10 additions & 10 deletions src/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@drawable/ic_launcher"
android:roundIcon="@drawable/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@drawable/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<meta-data android:name="android.max_aspect" android:value="2.1" />
<meta-data
android:name="android.max_aspect"
android:value="2.1" />

<activity
android:name=".activities.repositories.RepositoriesActivity"
android:label="@string/app_name"
android:exported="true">
android:exported="true"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down Expand Up @@ -62,16 +64,14 @@
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<activity
android:name=".activities.translate.TranslateActivity" />
<activity
android:name=".activities.export.CreateGistActivity" />
<activity android:name=".activities.translate.TranslateActivity" />
<activity android:name=".activities.export.CreateGistActivity" />
<activity android:name=".activities.info.BrowserActivity" />
<activity android:name=".activities.translate.SearchStringActivity" />
<activity
android:name=".activities.SettingsActivity"
android:theme="@style/AppTheme.NoActionBar"
android:label="@string/settings">
android:label="@string/settings"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
Expand Down Expand Up @@ -58,25 +57,20 @@ protected void onCreate(Bundle savedInstanceState) {
mApplicationListView.setAdapter(mApplicationAdapter);
mApplicationListView.setLayoutManager(new LinearLayoutManager(this));

mApplicationAdapter.onItemClick = new ApplicationAdapter.OnItemClick() {
@Override
public void onClick(final Intent data) {
setResult(RESULT_OK, data);
finish();
}
mApplicationAdapter.onItemClick = data -> {
setResult(RESULT_OK, data);
finish();
};

mApplicationListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy > 0 || dy <= 0) {
final LinearLayoutManager manager = (LinearLayoutManager)
mApplicationListView.getLayoutManager();

if (manager.findFirstVisibleItemPosition() + manager.getChildCount() ==
manager.getItemCount()) {
mApplicationAdapter.loadMore();
}
final LinearLayoutManager manager = (LinearLayoutManager)
mApplicationListView.getLayoutManager();

if (manager.findFirstVisibleItemPosition() + manager.getChildCount() ==
manager.getItemCount()) {
mApplicationAdapter.loadMore();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
Expand All @@ -21,7 +20,6 @@
import android.widget.Toast;

import net.gsantner.opoc.preference.GsPreferenceFragmentCompat;
import net.gsantner.opoc.preference.SharedPreferencesPropertyBackend;

import io.github.lonamiwebs.stringlate.R;
import io.github.lonamiwebs.stringlate.classes.git.GitHub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void onPostGist(final View v) {
mRepo.applyTemplate(defaultResources[0], mLocale));
}
}
if (!new ContextUtils(this).isConnectedToInternet(R.string.no_internet_connection))
if (new ContextUtils(this).isOffline(R.string.no_internet_connection))
return;

final String description = mDescriptionEditText.getText().toString().trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void onCreateIssue(final View v) {
);
description = description.replace("%x", xml);
}
if (!new ContextUtils(this).isConnectedToInternet(R.string.no_internet_connection))
if (new ContextUtils(this).isOffline(R.string.no_internet_connection))
return;

CreateUrlActivity.launchIntent(this, Exporter.createIssueExporter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import android.widget.TextView;
import android.widget.Toast;

import net.gsantner.opoc.util.Callback;

import io.github.lonamiwebs.stringlate.R;

import static io.github.lonamiwebs.stringlate.utilities.Constants.EXTRA_ID;
Expand Down Expand Up @@ -57,12 +55,7 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected String doInBackground(Void... params) {
try {
return mPostUrlCallable.call(CreateUrlActivity.this, new Callback.a1<String>() {
@Override
public void callback(String s) {
publishProgress(s);
}
});
return mPostUrlCallable.call(CreateUrlActivity.this, this::publishProgress);
} catch (Exception e) {
e.printStackTrace();
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;

import io.github.lonamiwebs.stringlate.R;
import io.github.lonamiwebs.stringlate.activities.SettingsActivity;
import io.github.lonamiwebs.stringlate.settings.AppSettings;
import net.gsantner.opoc.format.markdown.SimpleMarkdownParser;
import net.gsantner.opoc.preference.GsPreferenceFragmentCompat;
import net.gsantner.opoc.util.ActivityUtils;
import net.gsantner.opoc.util.ShareUtil;

import java.io.IOException;
import java.util.Locale;

import io.github.lonamiwebs.stringlate.R;
import io.github.lonamiwebs.stringlate.activities.SettingsActivity;
import io.github.lonamiwebs.stringlate.settings.AppSettings;

public class MoreInfoFragment extends GsPreferenceFragmentCompat<AppSettings> {
public static final String TAG = "MoreInfoFragment";

Expand Down Expand Up @@ -190,7 +190,6 @@ public synchronized void doUpdatePreferences() {
}
appendPreference(person, (PreferenceGroup) pref);
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,24 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
}

// If the user presses enter on an EditText, select the next one
mOwnerEditText.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int kc, KeyEvent e) {
if (e.getAction() == KeyEvent.ACTION_DOWN && kc == KeyEvent.KEYCODE_ENTER) {
mRepositoryEditText.requestFocus();
return true;
}
return false;
mOwnerEditText.setOnKeyListener((v, kc, e) -> {
if (e.getAction() == KeyEvent.ACTION_DOWN && kc == KeyEvent.KEYCODE_ENTER) {
mRepositoryEditText.requestFocus();
return true;
}
return false;
});

// Or, if we're on the repository EditText, hide the keyboard
mRepositoryEditText.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int kc, KeyEvent e) {
if (e.getAction() == KeyEvent.ACTION_DOWN && kc == KeyEvent.KEYCODE_ENTER) {
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow(mRepositoryEditText.getWindowToken(), 0);
return true;
}
return false;
mRepositoryEditText.setOnKeyListener((v, kc, e) -> {
if (e.getAction() == KeyEvent.ACTION_DOWN && kc == KeyEvent.KEYCODE_ENTER) {
InputMethodManager imm = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow(mRepositoryEditText.getWindowToken(), 0);
return true;
}
return false;
});

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Expand All @@ -138,7 +133,8 @@ public boolean onKey(View v, int kc, KeyEvent e) {

//region UI events

@OnTextChanged(callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED, value = {R.id.github_ownerEditText, R.id.github_repositoryEditText})
@OnTextChanged(callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED, value =
{R.id.github_ownerEditText, R.id.github_repositoryEditText})
public void onGitHubRepoEditChanged(CharSequence newText) {
final String owner = mOwnerEditText.getText().toString().trim();
final String repository = mRepositoryEditText.getText().toString().trim();
Expand All @@ -149,13 +145,8 @@ public void onGitHubRepoEditChanged(CharSequence newText) {
}
}

private final View.OnClickListener onDiscoverClick = new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivityForResult(new Intent(getContext(),
DiscoverActivity.class), RESULT_REPO_DISCOVERED);
}
};
private final View.OnClickListener onDiscoverClick = view -> startActivityForResult(new Intent(getContext(),
DiscoverActivity.class), RESULT_REPO_DISCOVERED);

private final View.OnClickListener onNextClick = new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -217,7 +208,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
//region Checking and adding a new local "repository"

private void scanDownloadStrings(final RepoHandler repo) {
if (!new ContextUtils(getContext()).isConnectedToInternet(R.string.no_internet_connection))
if (new ContextUtils(getContext()).isOffline(R.string.no_internet_connection))
return;

new RepoSyncTask(getContext(), repo,
Expand Down
Loading