Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
Apply new about section, show contributors, remove defective permissi…
Browse files Browse the repository at this point in the history
…on checking for location on Android 6 below
  • Loading branch information
velitasali committed Mar 16, 2018
1 parent a0c96da commit 145be55
Show file tree
Hide file tree
Showing 198 changed files with 623 additions and 53 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.genonbeta.TrebleShot"
minSdkVersion 14
targetSdkVersion 27
versionCode 63
versionName "1.2.5.8"
versionCode 64
versionName "1.2.5.9"
}

lintOptions {
Expand Down
31 changes: 16 additions & 15 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/text_appName"
android:theme="@style/AppTheme">

<activity
android:name=".activity.HomeActivity"
android:label="@string/text_appName"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="genonbeta.intent.action.OPEN_RECEIVED_FILES"/>

<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Expand All @@ -50,33 +51,30 @@
<action android:name="genonbeta.intent.action.TREBLESHOT_SEND_MULTIPLE"/>

<category android:name="android.intent.category.DEFAULT"/>

<data android:mimeType="*/*"/>
</intent-filter>

<meta-data
android:name="android.service.chooser.chooser_target_service"
android:value=".service.DeviceChooserService"/>
</activity>

<activity
android:name=".activity.QRScannerActivity"
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true"
android:theme="@style/AppTheme.QRScannerTheme"
android:windowSoftInputMode="stateAlwaysHidden"/>

<activity
android:name=".activity.FilePickerActivity"
android:label="@string/text_fileExplorer"/>

<activity
android:name=".activity.TransactionActivity"
android:label="@string/text_transactionViewer"
android:theme="@style/AppTheme.NoActionBar"/>

<activity
android:name=".activity.PreferencesActivity"
android:label="@string/text_preferences"/>

<activity
android:name=".activity.TextEditorActivity"
android:label="@string/text_textEditor"/>
Expand All @@ -86,16 +84,21 @@
android:theme="@style/Base.Theme.AppCompat.Dialog">
<intent-filter>
<action android:name="com.genonbeta.intent.action.UPDATE_STORAGE_PATH"/>

<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

<activity
android:name=".activity.AboutActivity"
android:label="@string/text_about"
android:theme="@style/AppTheme.NoActionBar"/>

<service
android:name=".service.CommunicationService"
android:enabled="true"
android:label="@string/text_communicationService"
android:process=":transfer"/>

<service
android:name=".service.DeviceChooserService"
android:label="@string/text_chooserTargetService"
Expand All @@ -104,19 +107,17 @@
<action android:name="android.service.chooser.ChooserTargetService"/>
</intent-filter>
</service>

<service
android:name=".service.DeviceScannerService">
<service android:name=".service.DeviceScannerService">
<intent-filter>
<action android:name="genonbeta.intent.action.SCAN_DEVICES"/>
<action android:name="genonbeta.intent.action.ADD_IP"/>

<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>

<service android:name=".service.WorkerService"
android:label="@string/text_workerService" />
<service
android:name=".service.WorkerService"
android:label="@string/text_workerService"/>

<receiver
android:name=".receiver.NetworkStatusReceiver"
Expand All @@ -128,7 +129,6 @@
<action android:name="android.net.wifi.p2p.CONNECTION_STATE_CHANGE"/>
</intent-filter>
</receiver>

<receiver
android:name=".receiver.DialogEventReceiver"
android:process=":transfer"/>
Expand All @@ -154,4 +154,5 @@
android:resource="@xml/provider_paths"/>
</provider>
</application>
</manifest>

</manifest>
108 changes: 108 additions & 0 deletions app/src/main/java/com/genonbeta/TrebleShot/activity/AboutActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package com.genonbeta.TrebleShot.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.genonbeta.TrebleShot.R;
import com.genonbeta.TrebleShot.config.AppConfig;

import velitasali.updatewithgithub.GitHubUpdater;

public class AboutActivity extends AppCompatActivity
{
private SharedPreferences mPreferences;
private GitHubUpdater mUpdater;

private TextView mTextUpdates;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mUpdater = new GitHubUpdater(this, AppConfig.URI_REPO_APP_UPDATE, R.style.AppTheme);

mTextUpdates = findViewById(R.id.activity_about_update_text);

findViewById(R.id.fab).setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("*/*");
intent.setData(Uri.parse("mailto:" + AppConfig.EMAIL_DEVELOPER));
intent.putExtra(Intent.EXTRA_EMAIL, AppConfig.EMAIL_DEVELOPER);
intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.text_appName));

startActivity(Intent.createChooser(intent, getString(R.string.text_application)));
}
});

findViewById(R.id.activity_about_see_source_layout).setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(AppConfig.URI_REPO_APP)));
}
});

findViewById(R.id.activity_about_translate_layout).setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(AppConfig.URI_TRANSLATE)));
}
});

findViewById(R.id.activity_about_update_layout).setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
mUpdater.checkForUpdates(true, null);
}
});

if (mPreferences.contains("availableVersion") && mUpdater.isNewVersion(mPreferences.getString("availableVersion", null)))
highlightUpdater(mPreferences.getString("availableVersion", null));
else
mUpdater.checkForUpdates(false, new GitHubUpdater.OnInfoAvailableListener()
{
@Override
public void onInfoAvailable(boolean newVersion, String versionName, String title, String description, String releaseDate)
{
mPreferences.edit()
.putString("availableVersion", versionName)
.apply();

if (newVersion)
highlightUpdater(versionName);
}
});
}

private void highlightUpdater(String availableVersion)
{
mTextUpdates.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.colorAccent));
mTextUpdates.setText(R.string.text_newVersionAvailable);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.genonbeta.TrebleShot.activity;

import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
Expand All @@ -20,7 +19,6 @@
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -68,12 +66,12 @@ public class HomeActivity extends Activity implements NavigationView.OnNavigatio

public static final int REQUEST_PERMISSION_ALL = 1;

private GitHubUpdater mUpdater;
private FloatingActionButton mFAB;
private SharedPreferences mPreferences;
private PowerfulActionMode mActionMode;
private NavigationView mNavigationView;
private DrawerLayout mDrawerLayout;
private GitHubUpdater mUpdater;
private Fragment mCurrentFragment;
private Fragment mFragmentDeviceList;
private Fragment mFragmentFileExplorer;
Expand Down Expand Up @@ -107,7 +105,7 @@ protected void onCreate(Bundle savedInstanceState)
toggle.syncState();
}

mUpdater = new GitHubUpdater(this, AppConfig.REPO_APP_UPDATE, R.style.AppTheme);
mUpdater = new GitHubUpdater(this, AppConfig.URI_REPO_APP_UPDATE, R.style.AppTheme);
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mActionMode = findViewById(R.id.content_powerful_action_mode);
mNavigationView = findViewById(R.id.nav_view);
Expand Down Expand Up @@ -220,27 +218,11 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item)
} else if (R.id.menu_activity_main_share_text == item.getItemId()) {
changeFragment(mFragmentShareText);
} else if (R.id.menu_activity_main_about == item.getItemId()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setTitle(R.string.text_about);
builder.setMessage(R.string.text_aboutSummary);
builder.setNegativeButton(R.string.butn_close, null);
builder.setPositiveButton(R.string.butn_seeSourceCode, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(AppConfig.REPO_APP)));
}
});

builder.show();
startActivity(new Intent(this, AboutActivity.class));
} else if (R.id.menu_activity_main_send_application == item.getItemId()) {
sendThisApplication();
} else if (R.id.menu_activity_main_preferences == item.getItemId()) {
startActivity(new Intent(this, PreferencesActivity.class));
} else if (R.id.menu_activity_main_check_for_updates == item.getItemId()) {
mUpdater.checkForUpdates(true, null);
} else if (R.id.menu_activity_main_exit == item.getItemId()) {
stopService(new Intent(this, CommunicationService.class));
stopService(new Intent(this, DeviceScannerService.class));
Expand Down Expand Up @@ -326,7 +308,7 @@ public boolean checkRequestedFragment(Intent intent)

private void highlightUpdater(String availableVersion)
{
MenuItem item = mNavigationView.getMenu().findItem(R.id.menu_activity_main_check_for_updates);
MenuItem item = mNavigationView.getMenu().findItem(R.id.menu_activity_main_about);

item.setChecked(true);
item.setTitle(R.string.text_newVersionAvailable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public ArrayList<NetworkDevice> onLoad()
{
ArrayList<NetworkDevice> list = new ArrayList<>();

if (mFragment.getWifiManager().isWifiEnabled()
&& mFragment.hasLocationPermission()
&& mFragment.isLocationServiceEnabled()) {
if (mFragment.canReadScanResults()) {
for (ScanResult resultIndex : mFragment.getWifiManager().getScanResults()) {
if (!resultIndex.SSID.startsWith(AppConfig.PREFIX_ACCESS_POINT))
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ public class AppConfig
BUFFER_LENGTH_SMALL = 1024;

public final static String
REPO_APP_UPDATE = "https://api.github.com/repos/genonbeta/TrebleShot/releases",
REPO_APP = "http://github.com/genonbeta/TrebleShot",
EMAIL_DEVELOPER = "genonbeta@gmail.com",
URI_REPO_APP_UPDATE = "https://api.github.com/repos/genonbeta/TrebleShot/releases",
URI_REPO_APP_CONTRIBUTORS = "https://api.github.com/repos/genonbeta/TrebleShot/contributors",
URI_REPO_APP = "http://github.com/genonbeta/TrebleShot",
URI_GITHUB_PROFILE = "https://github.com/%s",
URI_TRANSLATE = "https://hosted.weblate.org/engage/TrebleShot/",
PREFIX_ACCESS_POINT = "TS_",
NETWORK_INTERFACE_WIFI = "wlan0",
NDS_COMM_SERVICE_NAME = "TSComm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ public void onPrepareDetach()
showCustomView(false);
}

public boolean canReadScanResults()
{
return getWifiManager().isWifiEnabled()
&& (Build.VERSION.SDK_INT < 23 || (hasLocationPermission() && isLocationServiceEnabled()));
}

public void checkRefreshing()
{
mSwipeRefreshLayout.setRefreshing(!DeviceScannerService
Expand Down Expand Up @@ -669,7 +675,7 @@ public void setOnListClickListener(AbsListView.OnItemClickListener listener)
public boolean validateLocationPermission()
{
if (Build.VERSION.SDK_INT < 23)
return false;
return true;

if (!hasLocationPermission()) {
createSnackbar(R.string.mesg_locationPermissionRequiredSelfHotspot)
Expand Down
Loading

0 comments on commit 145be55

Please sign in to comment.