Skip to content

Commit

Permalink
🐛 Add http request support configuration in android
Browse files Browse the repository at this point in the history
⬆️ Upgrade flutter sdk constraints.
🐛 removed hash work detection from link preview regex.
⬆️ upgrade list literals to support listerals
  • Loading branch information
TheAlphamerc committed Apr 3, 2021
1 parent 3cb7a5e commit 5dc2e22
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 50 deletions.
6 changes: 5 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Fwitter"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true"
>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
Expand All @@ -35,6 +37,8 @@
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<meta-data android:name="io.flutter.network-policy"
android:resource="@xml/network_security_config"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
8 changes: 8 additions & 0 deletions android/app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
2 changes: 1 addition & 1 deletion lib/helper/utility.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class Utility {
RegExp reg = RegExp(
r"([#])\w+|(https?|ftp|file|#)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
Iterable<Match> _matches = reg.allMatches(text);
List<String> resultMatches = List<String>();
List<String> resultMatches = <String>[];
for (Match match in _matches) {
if (match.group(0).isNotEmpty) {
var tag = match.group(0);
Expand Down
6 changes: 3 additions & 3 deletions lib/model/feedModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class FeedModel {
parentkey = map['parentkey'];
childRetwetkey = map['childRetwetkey'];
if (map['tags'] != null) {
tags = List<String>();
tags = <String>[];
map['tags'].forEach((value) {
tags.add(value);
});
}
if (map["likeList"] != null) {
likeList = List<String>();
likeList = <String>[];

final list = map['likeList'];

Expand Down Expand Up @@ -101,7 +101,7 @@ class FeedModel {
}
if (map['replyTweetKeyList'] != null) {
map['replyTweetKeyList'].forEach((value) {
replyTweetKeyList = List<String>();
replyTweetKeyList = <String>[];
map['replyTweetKeyList'].forEach((value) {
replyTweetKeyList.add(value);
});
Expand Down
10 changes: 5 additions & 5 deletions lib/state/chats/chatState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ChatState extends AppState {
.child(userId)
.once()
.then((DataSnapshot snapshot) {
_chatUserList = List<ChatMessage>();
_chatUserList = <ChatMessage>[];
if (snapshot.value != null) {
var map = snapshot.value;
if (map != null) {
Expand Down Expand Up @@ -144,7 +144,7 @@ class ChatState extends AppState {
.child(_channelName)
.once()
.then((DataSnapshot snapshot) {
_messageList = List<ChatMessage>();
_messageList = <ChatMessage>[];
if (snapshot.value != null) {
var map = snapshot.value;
if (map != null) {
Expand Down Expand Up @@ -205,7 +205,7 @@ class ChatState extends AppState {
/// Method will trigger every time when you send/recieve from/to someone messgae.
void _onMessageAdded(Event event) {
if (_messageList == null) {
_messageList = List<ChatMessage>();
_messageList = <ChatMessage>[];
}
if (event.snapshot.value != null) {
var map = event.snapshot.value;
Expand All @@ -226,7 +226,7 @@ class ChatState extends AppState {

void _onMessageChanged(Event event) {
if (_messageList == null) {
_messageList = List<ChatMessage>();
_messageList = <ChatMessage>[];
}
if (event.snapshot.value != null) {
var map = event.snapshot.value;
Expand All @@ -247,7 +247,7 @@ class ChatState extends AppState {

void _onChatUserAdded(Event event) {
if (_chatUserList == null) {
_chatUserList = List<ChatMessage>();
_chatUserList = <ChatMessage>[];
}
if (event.snapshot.value != null) {
var map = event.snapshot.value;
Expand Down
6 changes: 3 additions & 3 deletions lib/state/feedState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class FeedState extends AppState {
_feedlist = null;
notifyListeners();
kDatabase.child('tweet').once().then((DataSnapshot snapshot) {
_feedlist = List<FeedModel>();
_feedlist = <FeedModel>[];
if (snapshot.value != null) {
var map = snapshot.value;
if (map != null) {
Expand Down Expand Up @@ -201,7 +201,7 @@ class FeedState extends AppState {

if (_tweetDetail != null) {
// Fetch comment tweets
_commentlist = List<FeedModel>();
_commentlist = <FeedModel>[];
// Check if parent tweet has reply tweets or not
if (_tweetDetail.replyTweetKeyList != null &&
_tweetDetail.replyTweetKeyList.length > 0) {
Expand Down Expand Up @@ -489,7 +489,7 @@ class FeedState extends AppState {
_onCommentAdded(tweet);
tweet.key = event.snapshot.key;
if (_feedlist == null) {
_feedlist = List<FeedModel>();
_feedlist = <FeedModel>[];
}
if ((_feedlist.length == 0 || _feedlist.any((x) => x.key != tweet.key)) &&
tweet.isValidTweet) {
Expand Down
2 changes: 1 addition & 1 deletion lib/state/notificationState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class NotificationState extends AppState {
var model = NotificationModel.fromJson(event.snapshot.key,
event.snapshot.value["updatedAt"], event.snapshot.value["type"]);
if (_notificationList == null) {
_notificationList = List<NotificationModel>();
_notificationList = <NotificationModel>[];
}
_notificationList.add(model);
// added notification to list
Expand Down
4 changes: 2 additions & 2 deletions lib/state/searchState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class SearchState extends AppState {
isBusy = true;
kDatabase.child('profile').once().then(
(DataSnapshot snapshot) {
_userlist = List<UserModel>();
_userFilterlist = List<UserModel>();
_userlist = <UserModel>[];
_userFilterlist = <UserModel>[];
if (snapshot.value != null) {
var map = snapshot.value;
if (map != null) {
Expand Down
5 changes: 3 additions & 2 deletions lib/widgets/url_text/customUrlText.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class UrlText extends StatelessWidget {
UrlText({this.text, this.style, this.urlStyle, this.onHashTagPressed});

List<InlineSpan> getTextSpans() {
List<InlineSpan> widgets = List<InlineSpan>();
List<InlineSpan> widgets = <InlineSpan>[];
RegExp reg = RegExp(
r"([#])\w+| [@]\w+|(https?|ftp|file|#)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
Iterable<Match> _matches = reg.allMatches(text);
List<_ResultMatch> resultMatches = List<_ResultMatch>();
List<_ResultMatch> resultMatches = <_ResultMatch>[];
int start = 0;
for (Match match in _matches) {
if (match.group(0).isNotEmpty) {
Expand Down Expand Up @@ -59,6 +59,7 @@ class UrlText extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RichText(
text: TextSpan(children: getTextSpans()),
Expand Down
10 changes: 8 additions & 2 deletions lib/widgets/url_text/custom_link_media_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CustomLinkMediaInfo extends StatelessWidget {
return null;
}
RegExp reg = RegExp(
r"([#])\w+| [@]\w+|(https?|ftp|file|#)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
r"(https?|http)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
Iterable<Match> _matches = reg.allMatches(text);
if (_matches.isNotEmpty) {
return _matches.first.group(0);
Expand Down Expand Up @@ -125,7 +125,13 @@ class CustomLinkMediaInfo extends StatelessWidget {
),
),
),
Padding(
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: model.thumbnailUrl != null
? Theme.of(context).colorScheme.onPrimary
: const Color(0xFFF0F1F2),
),
padding:
EdgeInsets.only(bottom: 5, left: 8, right: 8, top: 4),
child: Column(
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/url_text/link_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LinkPreview extends StatelessWidget {
return null;
}
RegExp reg = RegExp(
r"([#])\w+| [@]\w+|(https?|ftp|file|#)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
r"(https?|http)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]*");
Iterable<Match> _matches = reg.allMatches(text);
if (_matches.isNotEmpty) {
return _matches.first.group(0);
Expand Down Expand Up @@ -62,7 +62,7 @@ class LinkPreview extends StatelessWidget {
borderRadius: BorderRadius.circular(10),
border: Border.all(color: AppColor.extraLightGrey),
color: webInfo.image != null
? Colors.transparent
? Theme.of(context).colorScheme.onPrimary
: const Color(0xFFF0F1F2),
),
child: Column(
Expand Down
Loading

0 comments on commit 5dc2e22

Please sign in to comment.